diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-03-05 20:16:14 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-03-05 20:16:14 +0100 |
| commit | 5860237d2f05f6ae45a98569b0d567c2227904c6 (patch) | |
| tree | bbddb91e2a6a5e7efe7825971c726a9e4db87dd6 /src/zadd.c | |
| parent | More detailed description of division and modulus (diff) | |
| download | libzahl-5860237d2f05f6ae45a98569b0d567c2227904c6.tar.gz libzahl-5860237d2f05f6ae45a98569b0d567c2227904c6.tar.bz2 libzahl-5860237d2f05f6ae45a98569b0d567c2227904c6.tar.xz | |
Fix bugs and add a randomised testing
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zadd.c')
| -rw-r--r-- | src/zadd.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -9,16 +9,20 @@ zadd_unsigned(z_t a, z_t b, z_t c) uint32_t carry[] = {0, 0}; zahl_char_t *addend; - if (a == c) { - zadd_unsigned(a, c, b); + if (zzero(b)) { + zabs(a, c); + return; + } else if (zzero(c)) { + zabs(a, b); return; } size = MAX(b->used, c->used); + n = b->used + c->used - size; + ENSURE_SIZE(a, size + 1); a->chars[size] = 0; - n = b->used + c->used - size; if (a == b) { if (a->used < c->used) { n = c->used; @@ -56,7 +60,7 @@ zadd_unsigned(z_t a, z_t b, z_t c) if (a->used < i) a->used = i; - SET_SIGNUM(a, !zzero(b) | !zzero(c)); + SET_SIGNUM(a, 1); } |
