Bug #3746
closedIncorrect Float subtraction
Description
=begin
This is copied from IRB:
ruby-1.9.2-p0 > 2.0 - 1.0
=> 1.0
ruby-1.9.2-p0 > 2.0 - 1.1
=> 0.8999999999999999
ruby-1.9.2-p0 > 2.0 - 1.2
=> 0.8
ruby-1.9.2-p0 > 2.0 - 1.3
=> 0.7
ruby-1.9.2-p0 > 2.0 - 1.4
=> 0.6000000000000001
ruby-1.9.2-p0 > 2.0 - 1.5
=> 0.5
ruby-1.9.2-p0 > 2.0 - 1.6
=> 0.3999999999999999
ruby-1.9.2-p0 > 2.0 - 1.7
=> 0.30000000000000004
ruby-1.9.2-p0 > 2.0 - 1.8
=> 0.19999999999999996
ruby-1.9.2-p0 > 2.0 - 1.9
=> 0.10000000000000009
=end
Updated by naruse (Yui NARUSE) about 14 years ago
- Status changed from Open to Rejected
=begin
Read this.
What Every Computer Scientist Should Know About Floating-Point Arithmetic
http://docs.sun.com/source/806-3568/ncg_goldberg.html
=end
Updated by rogerdpack (Roger Pack) about 14 years ago
=begin
Here's another explanation:
http://wiki.github.com/rdp/ruby_tutorials_core/ruby-talk-faq#floats_imprecise
=end
Updated by kstephens (Kurt Stephens) about 14 years ago
=begin
More explanation:
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
Maybe there should be references to these pages in the Float RDOC?
=end