Issue #7676 has been reported by simonrussell (Simon Russell). ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676 Author: simonrussell (Simon Russell) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-09 03:11
on 2013-01-09 15:00
Issue #7676 has been updated by charliesome (Charlie Somerville).
File bug-7676.patch added
=begin
Attached a patch fixing this issue - the pointer equality checks in
(({recursive_equal})) and (({rb_equal})) should not be performed as this
breaks in the case where (({a != a})).
I'm not committing this straight away because it causes three test
failures due to brittle mocks.
=end
----------------------------------------
Bug #7676: Comparison of Float::NAN in array behaves unexpectedly
https://bugs.ruby-lang.org/issues/7676#change-35304
Author: simonrussell (Simon Russell)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]
It seems that two arrays containing Float::NAN will be considered equal
([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN !=
Float::NAN.
Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug
can be reproduced in Ruby 1.8 as well.) Results below.
1.8.7 p371
---------
1.8.7 :001 > nan = 0.0/0.0
=> NaN
1.8.7 :002 > nan == nan
=> false
1.8.7 :003 > [nan] == [nan]
=> true
1.9.3 p362
---------
1.9.3p362 :001 > Float::NAN == Float::NAN
=> false
1.9.3p362 :002 > [Float::NAN] == [Float::NAN]
=> true
2.0.0 preview2
on 2013-01-09 15:41
Issue #7676 has been updated by ngoto (Naohisa Goto). Status changed from Open to Rejected duplicate of Bug #1720 See documentation in numeric.c added in r37546 https://bugs.ruby-lang.org/projects/ruby-trunk/rep... ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35305 Author: simonrussell (Simon Russell) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-10 01:22
Issue #7676 has been updated by simonrussell (Simon Russell). This isn't just Float::NAN, actually; as Charlie's patch shows, it's actually any object that always returns false from == 1.9.3p125 :001 > class X 1.9.3p125 :002?> def ==(other) 1.9.3p125 :003?> false 1.9.3p125 :004?> end 1.9.3p125 :005?> end => nil 1.9.3p125 :006 > x = X.new => #<X:0x00000000ba1648> 1.9.3p125 :007 > x == x => false 1.9.3p125 :008 > [x] == [x] => true Is this desirable behaviour? ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35306 Author: simonrussell (Simon Russell) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-10 01:24
Issue #7676 has been updated by simonrussell (Simon Russell). At the very least, the documentation for Array#== should be updated to state that it first does an object identity comparison, then calls == only if the objects aren't the same instance. ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35307 Author: simonrussell (Simon Russell) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-10 03:19
Issue #7676 has been updated by hasari (Hiro Asari). I, too, found documentation still lacking. I read #1720, and I understand the rationale for the Float::NAN case. However, the issue still remains as Simon pointed out above. Please reopen the issue, or update the documentation to reflect the behavior more closely. ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35309 Author: simonrussell (Simon Russell) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-10 03:28
Issue #7676 has been updated by ngoto (Naohisa Goto). Category set to DOC Status changed from Rejected to Open ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35310 Author: simonrussell (Simon Russell) Status: Open Priority: Normal Assignee: Category: DOC Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-10 03:31
Issue #7676 has been updated by mrkn (Kenta Murata). Assignee set to matz (Yukihiro Matsumoto) Target version set to next minor I think this is the specification issue, so we need to confirm the mat'z thought. Matz, how do you think about it? ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35311 Author: simonrussell (Simon Russell) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: DOC Target version: next minor ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2
on 2013-01-10 03:39
Issue #7676 has been updated by charliesome (Charlie Somerville).
=begin
I understand that matz wants (({nan == nan})) to be undefined, but I
think this should remain consistent within a platform, even though it is
undefined between platforms.
=end
----------------------------------------
Bug #7676: Comparison of Float::NAN in array behaves unexpectedly
https://bugs.ruby-lang.org/issues/7676#change-35312
Author: simonrussell (Simon Russell)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: DOC
Target version: next minor
ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]
It seems that two arrays containing Float::NAN will be considered equal
([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN !=
Float::NAN.
Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug
can be reproduced in Ruby 1.8 as well.) Results below.
1.8.7 p371
---------
1.8.7 :001 > nan = 0.0/0.0
=> NaN
1.8.7 :002 > nan == nan
=> false
1.8.7 :003 > [nan] == [nan]
=> true
1.9.3 p362
---------
1.9.3p362 :001 > Float::NAN == Float::NAN
=> false
1.9.3p362 :002 > [Float::NAN] == [Float::NAN]
=> true
2.0.0 preview2
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.