In your code example, the multiplication of n by 10**12 uses floating point arithmetic, which introduces a rounding error. Instead, it needs to convert n to an exact rational number before doing the multiplication. ```ruby x = 658036...AndrewDile (Andrew Dile)
I'm proposing a replacement of `missing/dtoa.c` with a faster, leaner, more correct algorithm. I have [a PR](https://github.com/ruby/ruby/pull/18373) open as a proposed solution, which also provides more details to the origin of the algo...AndrewDile (Andrew Dile)
``` c Rational(65803600513127829623, 10**12).to_f ``` The bignum numerator cannot be exactly represented by a double, but the code in `rb_big_fdiv_double` rounds it to a double (`dx`) before dividing by the fixnum denominator of 10^12...AndrewDile (Andrew Dile)