Issue with precision of Ruby math operations
问题 Do you know how to fix the following issue with math precision? p RUBY_VERSION # => "1.9.1" p 0.1%1 # => 0.1 p 1.1%1 # => 0.1 p 90.0%1 # => 0.0 p 90.1%1 # => 0.0999999999999943 p 900.1%1 # => 0.100000000000023 p RUBY_VERSION # => "1.9.2" p 0.1%1 # => 0.1 p 1.1%1 # => 0.10000000000000009 p 90.0%1 # => 0.0 p 90.1%1 # => 0.09999999999999432 p 900.1%1 # => 0.10000000000002274 回答1: Big Decimal As the man said; Squeezing infinitely many real numbers into a finite number of bits requires an