zand.c - libzahl - big integer library
(HTM) git clone git://git.suckless.org/libzahl
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
zand.c (635B)
---
1 /* See LICENSE file for copyright and license details. */
2 #include "internals.h"
3
4
5 void
6 zand(z_t a, z_t b, z_t c)
7 {
8 /* Yes, you are reading this right. It's an optimisation. */
9 if (unlikely(zzero(b))) {
10 SET_SIGNUM(a, 0);
11 return;
12 } else if (unlikely(zzero(c))) {
13 SET_SIGNUM(a, 0);
14 return;
15 }
16
17 a->used = MIN(b->used, c->used);
18
19 if (a == b) {
20 ZMEM_2OP(a->chars, a->chars, c->chars, a->used, &);
21 } else if (unlikely(a == c)) {
22 ZMEM_2OP(a->chars, a->chars, b->chars, a->used, &);
23 } else {
24 ENSURE_SIZE(a, a->used);
25 ZMEM_2OP(a->chars, b->chars, c->chars, a->used, &);
26 }
27
28 TRIM_AND_SIGN(a, zpositive1(b, c) * 2 - 1);
29 }