Changeset 33131 in project


Ignore:
Timestamp:
01/25/16 20:38:57 (4 years ago)
Author:
sjamaan
Message:

numbers: Fix "overlap" handling for power of two radices

This resulted in assertion failures or leading zeroes when radix bit
length wasn't an exact divisor of bignum digit bit size.

Location:
release/4/numbers/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r32731 r33131  
    23952395        big_digit = *scan++;
    23962396        radix_digit |= (big_digit << big_digit_len) & radix_mask;
     2397        *index-- = characters[radix_digit];
    23972398        big_digit >>= (radix_shift - big_digit_len);
    2398         big_digit_len = C_BIGNUM_DIGIT_LENGTH - big_digit_len;
     2399        big_digit_len = C_BIGNUM_DIGIT_LENGTH - (radix_shift - big_digit_len);
    23992400      }
    24002401
  • release/4/numbers/trunk/tests/numbers-test.scm

    r32735 r33131  
    10011001       "10000000000000000000000000000000000000000000000000000000000000000"
    10021002       (number->string (expt 2 256) 16))
     1003 (test "non-exact multiple of 64 length edge case printing"
     1004       "4000000000000000000000" (number->string (expt 2 65) 8))
     1005 (test "another non-exact multiple of 64 length edge case printing"
     1006       "200000000000000000000000" (number->string (expt 2 70) 8))
     1007 (test "edge case length calculation"
     1008       "10000000000000000000000000000000000000000000000000000000000000000000000" (number->string (expt 2 210) 8))
    10031009 (test "positive hexdigit invariance"
    10041010       "123456789abcdef123456789abcdef123456789abcdef"
Note: See TracChangeset for help on using the changeset viewer.