Skip to content

Fix #274: 1d999999 hangs cmucl

Raymond Toy requested to merge issue-274-make-float-of-huge-numbers into master

Modify make-float-aux to process the parts of a float better. This means passing in the exponent directly.

The number, x, to be computed is number*10^exponent/divisor. Compute the base 2 log of this to get an approximate size of the number. If this exponent is too small or too large, immediately signal a reader-error. The limits chosen are basically twice the smallest and largest base 2 exponents of the float, to account for round-off error in the log2 computation. We don't need to be super accurate here; the rest of the code will handle it fine.

Also modify the error message to print the string that caused the issue. This is more informative than the (possibly huge) rational that used to be printed. Thus, trying to read "1d999999" will produce a reader-error and print out that we can't convert "1d999999" to a float.

Now 1d9999999 instantly throws an error instead of trying to compute 10^9999999. And similarly 1d-9999999 immediately signals an error instead of trying to compute 10^-9999999.

Edited by Raymond Toy

Merge request reports