Introduction
Introduction Statistics Contact Development Disclaimer Help
zmodpowu.c - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
zmodpowu.c (683B)
---
1 /* See LICENSE file for copyright and license details. */
2 #include "internals.h"
3
4 #define tb libzahl_tmp_pow_b
5 #define td libzahl_tmp_pow_d
6
7
8 void
9 zmodpowu(z_t a, z_t b, unsigned long long int c, z_t d)
10 {
11 if (unlikely(!c)) {
12 if (check(zzero(b)))
13 libzahl_failure(-ZERROR_0_POW_0);
14 else if (check(zzero(d)))
15 libzahl_failure(-ZERROR_DIV_0);
16 else
17 zsetu(a, 1);
18 return;
19 } else if (check(zzero(d))) {
20 libzahl_failure(-ZERROR_DIV_0);
21 } else if (unlikely(zzero(b))) {
22 SET_SIGNUM(a, 0);
23 return;
24 }
25
26 zmod(tb, b, d);
27 zset(td, d);
28
29 if (c & 1)
30 zset(a, tb);
31 else
32 zsetu(a, 1);
33 while (c >>= 1) {
34 zmodsqr(tb, tb, td);
35 if (c & 1)
36 zmodmul(a, a, tb, td);
37 }
38 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.