Bug #3640

BigDecimal#hash returns -2 for all negative finite numbers.

Added by Kenta Murata about 5 years ago. Updated over 4 years ago.

[ruby-core:31582]
Status:Closed
Priority:Normal
Assignee:Kenta Murata
ruby -v:ruby 1.9.3dev (2010-08-01 trunk 28823) [x86_64-darwin10.4.0] Backport:

Description

=begin
$ ruby -rbigdecimal -ve '

a = []
b = BigDecimal("-1")
10.times { a << b *= 10 }
h = {}
a.each_with_index {|x, i| h[x] = i }
p a.all? {|x, i| i == h[x] }'
ruby 1.9.3dev (2010-08-01 trunk 28823) [x86_64-darwin10.4.0]
false
=end

History

#1 Updated by Kenta Murata about 5 years ago

=begin
Sorry, the code I've shown is improper.

The proper code is here:

$ ruby -rbigdecimal -ve '
a = []
b = BigDecimal("-1")
10.times { a << (b *= 10).hash }
p a'
ruby 1.9.3dev (2010-08-01 trunk 28823) [x86_64-darwin10.4.0]
[-2, -2, -2, -2, -2, -2, -2, -2, -2, -2]

=end

#2 Updated by Kenta Murata about 5 years ago

  • Status changed from Assigned to Closed

=begin
This bug fixed by r28825.

=end

Also available in: Atom PDF