Issue #22246 has been updated by byroot (Jean Boussier). [Feature #21308] was filed a while ago. `dtoa.c` is really showing its age, and in the last couple years there has been a lot of new algorithms on that particular topic. Currently `ruby/json` uses Grisu for `double -> string` and Eisel-Lemire fast float for `string -> double`. If these benchmarks are to be believed: https://fmtlib.github.io/dtoa-benchmark/results/, `uscale` while much simpler than alternatives, may not be the best choice. If we're to migrate away from `dtoa.c` I think we might as well consider several alternatives rather than jump straight to `uscale`. So perhaps it'd be best to put [Feature #21308] on the next developer meeting topic to see what the criterias would be for replacement. ---------------------------------------- Bug #22246: Rational#to_f incorrectly rounds when the numerator is a bignum that cannot be represented exactly by a double, and the denominator is a fixnum https://bugs.ruby-lang.org/issues/22246#change-118673 * Author: AndrewDile (Andrew Dile) * Status: Open * ruby -v: 4.0.6 * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ``` 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, resulting in `65803600.51312783`, instead of the correctly rounded value, `65803600.513127826`. The `isinf(dx)` test does not cover this case. Moreover, not all fixnums (in 64-bit systems) can be represented exactly as doubles. -- https://bugs.ruby-lang.org/