aboutsummaryrefslogtreecommitdiffstats
path: root/src/zgcd.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-03 23:02:59 +0100
committerMattias Andrée <maandree@kth.se>2016-03-03 23:02:59 +0100
commitd6987458f21cf1890045f2606d0f8ec4d2225b44 (patch)
tree90afabbea01b01c4dedcb41748eb534ce04fbf77 /src/zgcd.c
parentzsets: minor optimisation (diff)
downloadlibzahl-d6987458f21cf1890045f2606d0f8ec4d2225b44.tar.gz
libzahl-d6987458f21cf1890045f2606d0f8ec4d2225b44.tar.bz2
libzahl-d6987458f21cf1890045f2606d0f8ec4d2225b44.tar.xz
Cleanup and fix bug in ztrunc
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zgcd.c')
-rw-r--r--src/zgcd.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/zgcd.c b/src/zgcd.c
index 7e65ebf..ec4ad62 100644
--- a/src/zgcd.c
+++ b/src/zgcd.c
@@ -17,18 +17,15 @@ zgcd(z_t a, z_t b, z_t c)
int neg;
if (!zcmp(b, c)) {
- if (a != b)
- zset(a, b);
+ SET(a, b);
return;
}
if (zzero(b)) {
- if (a != c)
- zset(a, c);
+ SET(a, c);
return;
}
if (zzero(c)) {
- if (a != b)
- zset(a, b);
+ SET(a, b);
return;
}
@@ -36,7 +33,7 @@ zgcd(z_t a, z_t b, z_t c)
zabs(v, c);
neg = zsignum(b) < 0 && zsignum(c) < 0;
- min = u->used < v->used ? u->used : v->used;
+ min = MIN(u->used, v->used);
for (; i < min; i++) {
uv = u->chars[i] | v->used[i];
for (bit = 1; bit; bit <<= 1, shifts++)