Project

General

Profile

Bug #13674

BigDecimal comparison with Float::INFINITY is erroneous in 2.2.x and 2.3.x

Added by Eregon (Benoit Daloze) over 1 year ago. Updated over 1 year ago.

Status:
Assigned
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
[ruby-core:81751]

Description

BigDecimal("-0.2E5556") > -Float::INFINITY

returns wrong results in MRI 2.2.x and 2.3.x:

for ruby in 2.0.0-p647 2.1.7 2.2.3 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 trunk; do chruby $ruby; ruby -v -rbigdecimal -e 'p BigDecimal("-0.2E5556") > -Float::INFINITY'; done
ruby 2.0.0p647 (2015-08-18) [x86_64-linux]
-e:1:in `to_r': -Infinity (FloatDomainError)
    from -e:1:in `>'
    from -e:1:in `<main>'
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]
-e:1:in `to_r': -Infinity (FloatDomainError)
    from -e:1:in `>'
    from -e:1:in `<main>'

ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
-e:1:in `to_r': -Infinity (FloatDomainError)
    from -e:1:in `>'
    from -e:1:in `<main>'

ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux]
false
ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-linux]
false

ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
-e:1:in `to_r': -Infinity (FloatDomainError)
    from -e:1:in `>'
    from -e:1:in `<main>'
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
-e:1:in `to_r': -Infinity (FloatDomainError)
    from -e:1:in `>'
    from -e:1:in `<main>'

ruby 2.3.2p217 (2016-11-15 revision 56796) [x86_64-linux]
false
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
false
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]
false

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
true
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
true
ruby 2.5.0dev (2017-06-13 trunk 59075) [x86_64-linux]
true

This was discovered by ruby/specs added in JRuby in https://github.com/jruby/jruby/pull/4618.

History

Updated by mrkn (Kenta Murata) over 1 year ago

  • Assignee set to mrkn (Kenta Murata)
  • Status changed from Open to Assigned

Also available in: Atom PDF