On Sun, Jul 3, 2022 at 8:10 AM James Cloos cloos@jhcloos.com wrote:
it looks like that bug only harms ratio. bignum integer seems to be ok.
so aworkarount is, in the caseof a ratio, to take the difference of the logs of the numerator and the denominator.
This is basically what cmucl does. But you have to be careful if the numerator and denominator are very close to each other. Then you'll take the difference of two logs that are essentially equal and lose lots or precision. IIRC, cmucl doesn't do this if the ratio is close to 1 because then converting to double-float isn't a problem. There are other ways to handle this though, like implementing a log2 function that returns the integer part and the fraction separately so you don't lose too many fraction bits when the numbers are huge.
-JimC
James Cloos cloos@jhcloos.com OpenPGP: 0x997A9F17ED7DAEA6