Project

General

Profile

Bug #17214

Updated by sawa (Tsuyoshi Sawada) about 4 years ago

This is an incorrect value: 

 ```ruby 
 > (BigDecimal("2222") ** BigDecimal("3.5")).to_i 
 # => 517135311000 
 ``` 

 This is the correct value (within Float precision): an incorrect value. 

 ```ruby 
 > 2222 ** 3.5 
 # => 517135308457.25256 
 ``` This is the correct value (within Float precision). 

 As the Base gets larger, the problem is more visible. Wrong value, number of trailing zeroes increase: 

 ```ruby visible: 
 > (BigDecimal("22222") ** BigDecimal("3.5")).to_i 
 # => 1635840670000000 
 ``` Wrong value, number of trailing zeroes increase. 

 Nearing maximum Float precision: 

 ```ruby 
 > 22222 ** 3.5 
 # => 1635840670214066.5 
 ``` (nearing maximum Float precision) 

Back