Project

General

Profile

Actions

Backport #5319

closed

Problem backporting [ruby-dev:38672] to 1.8.7p334

Added by brixen (Brian Shirai) over 13 years ago. Updated almost 8 years ago.


Description

It appears that the change in [ruby-dev:38672] was not backported correctly to 1.8.7p334

comparison.rb

inf = 1.0/0.0
b = Float::MAX.to_i * 2

p(inf <=> b) # => should be 1
p(b <=> inf) # => should be -1

p(inf <=> (-b)) # => should be 1
p((-b) <=> inf) # => should be -1

p((-inf) <=> b) # should be -1
p(b <=> (-inf)) # should be 1

p((-inf) <=> (-b)) # should be -1
p((-b) <=> (-inf)) # should be 1

$ ruby1.9.2 -v comparison.rb
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
1
-1
1
-1
-1
1
-1
1

$ ruby1.8.7 -v comparison.rb
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.8.0]
comparison.rb:4: warning: Bignum out of Float range
0
comparison.rb:5: warning: Bignum out of Float range
0
comparison.rb:7: warning: Bignum out of Float range
0
comparison.rb:8: warning: Bignum out of Float range
0
comparison.rb:10: warning: Bignum out of Float range
-1
comparison.rb:11: warning: Bignum out of Float range
1
comparison.rb:13: warning: Bignum out of Float range
-1
comparison.rb:14: warning: Bignum out of Float range
1

Thanks,
Brian


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #1645: 大きな数の比較で正しくない結果になることがあるClosed06/17/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0