blob: bc0c6dd29c6a8cae3828df9b7bc5f0c305c8555f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/* See LICENSE file for copyright and license details. */
#include "internals"
#include <errno.h>
#define tb libzahl_tmp_pow_b
void
zpowu(z_t a, z_t b, unsigned long long int c)
{
if (!c) {
if (zzero(b)) {
errno = EDOM; /* Indeterminate form: 0:th power of 0 */
FAILURE_JUMP();
}
zsetu(a, 1);
return;
} else if (zzero(b)) {
SET_SIGNUM(a, 0);
return;
}
zset(tb, b);
zsetu(a, 1);
for (; c; c >>= 1) {
if (c & 1)
zmul(a, a, tb);
zsqr(tb, tb);
}
}
|