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/znot.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/znot.c')
| -rw-r--r-- | src/znot.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -18,12 +18,12 @@ znot(z_t a, z_t b) for (n = a->used; n--;) a->chars[n] = ~(a->chars[n]); - bits &= BITS_PER_CHAR - 1; - a->chars[a->used - 1] &= ((zahl_char_t)1 << bits) - 1; + bits = BITS_IN_LAST_CHAR(bits); + if (bits) + a->chars[a->used - 1] &= ((zahl_char_t)1 << bits) - 1; - for (; a->used; a->used--) - if (a->chars[a->used - 1]) - break; + while (a->used && !a->chars[a->used - 1]) + a->used--; if (!a->used) SET_SIGNUM(a, 0); } |
