I\'m writing a ruby program that uses floats. I\'m having trouble with the precision. For example
1.9.3p194 :013 > 113.0 * 0.01 # => 1.13000000000000
In calculation with float you should use sigma method - it means not to compare two values, but compare absolute difference of them with a very little value - 1e-10, for example.
((113 * 0.01) - 1.13).abs<1e-10