Project

General

Profile

Actions

Bug #3746

closed

Incorrect Float subtraction

Added by dim (Dimitrij Denissenko) about 14 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
Backport:
[ruby-core:31849]

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


Related issues 7 (0 open7 closed)

Related to Ruby master - Bug #4394: Bug in floating point multiplicationRejectedActions
Related to Ruby master - Bug #4135: bug in calculations in 1.9.3dev / 1.9.2Rejected12/08/2010Actions
Related to Ruby 1.8 - Bug #4023: to_i pathological case in 1.8.7, 1.9.2Rejected11/04/2010Actions
Related to Backport187 - Backport #3550: Floating Point Representation Prevents Raising to Fractional PowerClosedActions
Related to Ruby 1.8 - Bug #922: Float == is false when should be trueRejected12/23/2008Actions
Has duplicate Ruby master - Bug #3785: unexpected Numeric#step behaviourRejected09/04/2010Actions
Has duplicate Ruby master - Bug #4022: Mistake in this cocient of logs followed by %1Rejected11/04/2010Actions
Actions #1

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

Actions #3

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

Actions #4

Updated by naruse (Yui NARUSE) about 14 years ago

=begin
I added them.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0