Math correctness

Hello
Having 10000.0/33*5*11*3
using Ruby 1.9.3 I get 50000.0 exactly,
using ruby 2.1 (and above) I get 49999.999...
same with other calculations
- everytime older versions deliver better results!

I dont know what was changed,
so perhaps Float should be back(down)graded???

Berg

I get 49999.9... also for ruby-2.0.0-p643 and ruby-1.9.3-p551.

Anyway, you need to keep in mind that floating point calculations
are almost always affected by rounding errors, unavoidably.

Use BigDecimal for arbitrary precision decimal numbers.

Regards,
Marcus

ยทยทยท

Am 27.02.2016 um 11:22 schrieb A Berger:

Having 10000.0/33*5*11*3
using Ruby 1.9.3 I get 50000.0 exactly,
using ruby 2.1 (and above) I get 49999.999...

I have done it with irb
RUBY_VERSION
1.9.3
says 50000.0 (exactly)

Thanks for bigdec!