Issue #6958 has been updated by regularfry (Alex Young).


Sure.  I've created #6973 for this, although I've switched the method names around from my suggestion above.  I'm guessing there's rather more code relying on #integer?'s current implementation than I'd want to personally fix right now :-)

----------------------------------------
Feature #6958: buggy BigDecimal#integer?
https://bugs.ruby-lang.org/issues/6958#change-29162

Author: adrianomitre (Adriano Mitre)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: core
Target version: 


=begin
BigDecimal#integer? always return false, which is wrong in many cases, as shown below.

 x, y = BigDecimal('1'), BigDecimal('1.0')

 x.integer?
 #=> false

 y.integer?
 #=> false

 x == x.to_i
 #=> true

 y == y.to_i
 #=> true

 # Possible workaround
 #
 class BigDecimal
   def integer?
     self == self.to_i
   end
 end
=end



-- 
http://bugs.ruby-lang.org/