Project

General

Profile

Feature #3429

Updated by nahi (Hiroshi Nakamura) almost 13 years ago

=begin 
  
  Hi, 
 
  Trying to do 
  int**some_large_number can result in 
  "warning: in a**b, b may be too big" 
  #=> Infinity 
  By example, 
  2**7830457 
 
  It is not good behavior, as we can make a workaround and it works perfectly: 
  # 7830457 = 2 * 37 * 105817 - 1 
  n = (((2 ** 105817) ** 37) ** 2) / 2 # => ...8739992577 which is the good number 
 
  I think it is not consistent to return Infinity when a correct answer can be given. 
  And Integer**Integer should always return an Integer (Infinity is a Float) 
 
  Also, while doing some tests about this I noticed that "bignum == Float::INFINITY" or "bignum.infinite?" hangs, while it should not, as it is always false. 
 
  See the script attached for some details and a (nonsense) implementation Integer#int_pow method which show it is possible to get better results. 
 
 =end 
 

Back