General

Profile

AndrewDile (Andrew Dile)

Issues

open closed Total
Assigned issues 0 0 0
Reported issues 2 0 2

Activity

08/21/2026

02:15 PM Ruby 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
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)
01:47 PM Ruby Feature #22256 (Open): Replace missing/dtoa.c with a uscale-based algorithm. Faster, smaller footprint, and fixes a rounding error.
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)

08/14/2026

07:29 PM Ruby Bug #22246 (Open): 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
``` 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)

Also available in: Atom