Issue #6986 has been updated by mrkn (Kenta Murata).


I cannot reproduce NoMemoryError on my environment.
However I think the following behaviors for the large parameters may be inconsistent, so I will attempt to fix these behavior.

Unfortunately I may not be able to fix NoMemoryError because I don't have the environment of mswin32.
Please submit your patch for fixing it.

$ ruby-head -v
ruby 2.0.0dev (2012-09-06 trunk 36915) [x86_64-darwin11.4.0]
$
$ ruby-head -rbigdecimal -e 'p BigDecimal("1e-10").power(1e7)'
#<BigDecimal:7fbd51033f98,'0.1E-99999999',9(100000026)>
$
$ ruby-head -rbigdecimal -e 'p BigDecimal("1e-10").power(1e8)'
#<BigDecimal:7f8401033f90,'0.1E-999999999',9(1000000026)>
$
$ ruby-head -rbigdecimal -e 'p BigDecimal("1e-10").power(1e10)'
-e:1:in `power': integer 10000000000 too big to convert to `int' (RangeError)
        from -e:1:in `<main>'
$
$ ruby-head -rbigdecimal -e 'p BigDecimal("1e-10").power(1e19)'
#<BigDecimal:7fe595004998,'0.0',9(18)>

----------------------------------------
Bug #6986: Inconsistent result of BigDecimal#power
https://bugs.ruby-lang.org/issues/6986#change-29204

Author: phasis68 (Heesob Park)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 
ruby -v: ruby 2.0.0dev (2012-09-05 trunk 36913) [i386-mswin32_100]


I found BigDecimal#power returns incorrect result for a large value.

C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e7)"
#<BigDecimal:a2bdb8,'0.1E-99999999',9(100000026)>

C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e8)"
-e:1:in `power': failed to allocate memory (NoMemoryError)
        from -e:1:in `<main>'
	
C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e10)"
#<BigDecimal:f7cb3c,'0.0',9(18)>

C:\tmp>ruby -rbigdecimal -e "p BigDecimal('1e-10').power(1e19)"
#<BigDecimal:f7cb3c,'Infinity',9(18)>




-- 
http://bugs.ruby-lang.org/