Drew Raines wrote:
> Wolfgang NáÅasi-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...,

Almost all programming languages use binary floating point, so 0.30
can't be
represented exactly.  A very few languages use binary-coded decimal.
Examples: Decimal BASIC and Business BASIC (I think).  The BASIC
that came with the old 8-bit Atari used binary-coded decimal, so it
would
have had no problem with 3930-39.30*100.

Since computers of today are so much faster than 8-bit computers,
one would think that they could afford to incur the speed penalty
associated with binary-coded decimal.