Project

General

Profile

Actions

Feature #6958

closed

buggy BigDecimal#integer?

Added by adrianomitre (Adriano Mitre) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
-
[ruby-core:47386]

Description

=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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0