aboutsummaryrefslogtreecommitdiffstats
path: root/src/zdivmod.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/zdivmod.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/zdivmod.c')
-rw-r--r--src/zdivmod.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/zdivmod.c b/src/zdivmod.c
index bf5dfa6..70b1f5c 100644
--- a/src/zdivmod.c
+++ b/src/zdivmod.c
@@ -36,8 +36,8 @@ zdivmod(z_t a, z_t b, z_t c, z_t d)
return;
} else if (sign < 0) {
zsub_unsigned(b, d, c);
- } else if (b != c) {
- zset(b, c);
+ } else {
+ SET(b, c);
}
SET_SIGNUM(b, 1);
SET_SIGNUM(a, 0);
@@ -82,13 +82,13 @@ zdivmod(z_t a, z_t b, z_t c, z_t d)
goto done;
zrsh(td[i], td[i], 1);
}
- for (i = bit < BITS_PER_CHAR ? bit : BITS_PER_CHAR; i--;)
+ for (i = MIN(bit, BITS_PER_CHAR); i--;)
zrsh(tds[i], tds[i], BITS_PER_CHAR);
}
}
done:
- zset(a, ta);
- zset(b, tb);
+ zswap(a, ta);
+ zswap(b, tb);
SET_SIGNUM(a, sign);
}