Wolfgang Ndasi-Donner wrote:

> irb(main):001:0> 3930-39.30*100
> => 4.54747350886464e-013
>
> Rounding errors are typical for floating point numbers. In this case
> the result of -39.30*100 ist a little bit smaller than 3930, so to_i
> works correct.

When I think of rounding error, I think of lost precision due to
rounding too early in a series of floating point calculations.  When
multiplying a non-repeating Float point by 100, shouldn't the decimal
move over two places without introducing extra precision?

And how can 39.30*100 really be 3930.000000000000454747350886464...,
but 39.31*100 be 3931.0?

BigDecimal seems to be unaffected, so I guess I'll use that as a
workaround:

  >> (39.30*100).to_i
  => 3929
  >> (39.30*100).to_d.to_i
  => 3930

Thanks for your response.

-Drew