From: nahi Date: 2012-03-18T16:50:23+09:00 Subject: [ruby-core:43409] [ruby-trunk - Feature #3429] Integer#**(large) warns "in a**b, b may be too big" and return Infinity Issue #3429 has been updated by nahi. Description updated Assignee set to mrkn mrkn, please handle this. ---------------------------------------- Feature #3429: Integer#**(large) warns "in a**b, b may be too big" and return Infinity https://bugs.ruby-lang.org/issues/3429#change-24722 Author: Eregon Status: Open Priority: Normal Assignee: mrkn Category: core Target version: 2.0.0 =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 -- http://bugs.ruby-lang.org/