Project

General

Profile

Bug #9192

Inconsistent comparison between Float and BigDecimal

Added by vatsu (Gustavo Sales) over 6 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin11.4.2]
[ruby-core:58756]

Description

I was checking a possible inconsistency on ActiveModel and I found situations where comparing BigDecimal to Float differs to comparing Float to BigDecimal.

I have create a simple ruby script to exemplify the problem. The script is attach to this issue and output is as follows:

Instance number 706.05
###########
Instance number 706.06
Inconsistence:
0.70606E3 > 706.06

706.06 < 0.70606E3

Inconsistence:
0.70606E3 <= 706.06

706.06 >= 0.70606E3

###########
Instance number 706.07
Inconsistence:
0.70607E3 < 706.07

706.07 > 0.70607E3

Inconsistence:
0.70607E3 >= 706.07

706.07 <= 0.70607E3

###########
Instance number 706.08
###########


Files

compare_decimal_float.rb (529 Bytes) compare_decimal_float.rb vatsu (Gustavo Sales), 12/02/2013 09:01 AM

Related issues

Related to Ruby master - Feature #8295: Float や Rational から(可能であれば)正確な BigDecimal を生成する機能Assignedmrkn (Kenta Murata)Actions

Also available in: Atom PDF