1.9 KiB
State of Play
20250313
OK, the 60 bit integer cell happens in int128_to_integer
in arith/integer.c
. It seems to be being done consistently; but there is no obvious reason. MAX_INTEGER
is defined in arith/peano.h
. I've changed both to use 63 bits, and this makes no change to the number of unit tests that fail.
With this change, (fact 21)
, which was previously printing nothing, now prints a value, 11,891,611,015,076,642,816
. However, this value is definitively wrong, should be 51,090,942,171,709,440,000
. But, I hadn't fixed the shift in integer_to_string
; have now... still no change in number of failed tests...
But (fact 21)
gives a different wrong value, 4,974,081,987,435,560,960
. Factorial values returned by fact
are correct (agree with SBCL running the same code) up to (fact 20)
, with both 60 bit integer cells and 63 bit integer cells giving correct values.
Uhhhmmm... but I'd missed two other places where I'd had the number of significant bits as a numeric literal. Fixed those and now (fact 21)
does not return a printable answer at all, although the internal representation is definitely wrong. So we may be seeing why I chose 60 bits.
Bother.
20250312
Printing of bignums definitely doesn't work; I'm not persuaded that reading of bignums works right either, and there are probably problems with bignum arithmetic too.
The internal memory representation of a number rolls over from one cell to two cells at 1152921504606846976, and I'm not at all certain why it does because this is neither 263 nor 264.
262 | 4611686018427387904 | |
263 | 9223372036854775808 | |
264 | 18446744073709551616 | |
Mystery number | 1152921504606846976 |
In fact, our mystery number turns out (by inspection) to be 260. But why?