Please sign in to comment.
Fix drift in Num->Str roundtrip; Make nqp::div_In 14x slower
Fixes R#1651 rakudo/rakudo#1651 The original code converted bigints to doubles right away, before dividing them, which caused some precision loss that was responsible for repeated Num->Str conversion to drift the value. Fix by scaling up the divident by the bits of the divisor + additional 64 bits (that's needed to get correct answers for stuff like 1e-300). Then performing integer division, and then converting the result to double, and reversing the original scaling inside the to-double conversion routine. Since we combine the scaling and denormals handling, we need to break up the shift by power of two we do in the to-double conversion routine to do it in 2**1023 steps (otherwise, the 2 raised to a larger power becomes Inf (or denormal/-Inf for negative powers). This work makes nqp::div_In op 14x slower, but I'm hopeful that after the CaR grant, to have extra knowledge to speed it up.
- Loading branch information...