Project

General

Profile

Feature #6958

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

=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 

Back