From: Christian Luginbuehl Date: 2007-08-20T04:06:44+09:00 Subject: Re: Float addition problem / Processor bug? >> Is it a processor bug, a simple rounding problem or a ruby error? > > The second one. This is a standard rounding issue. The short > explanation is that you see the numbers in decimal system while the > computer uses binary representation for floats. I kind of knew it ;-) - but still thank you Robert for confirming! >> How do I proceed? > > Live with it or use other data types like BigDecimal or Rational. > > [ SNIP irb code ] I changed my app to use BigDecimal now and it works fine this way. However I don't like this Float behaviour of Ruby. Especially that the String representation of such values looks correct, while testing for equality says 'false' - like this: === START irb output === irb(main):014:0> a = 2.95 + 2.95 + 2.95 => 8.85 irb(main):015:0> puts a 8.85 => nil irb(main):016:0> puts a == 8.85 false => nil === END irb output === With whole numbers the conversion from Fixnum to Bignum is transparent to the user and makes life a lot easier. Wouldn't it be possible to have the same behaviour with floating point numbers? Dinkel