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


phasis68 (Heesob Park) wrote:
> This issue was solved with changeset r41623.
> BTW, my patch is same to Garth Snyder's and it is 11 months old.

I'm sorry I missed this issue and your patch.
I added your name in ChangeLog at r41723.

----------------------------------------
Bug #6862: BigMath.exp negative exponent
https://bugs.ruby-lang.org/issues/6862#change-40225

Author: karatedog (Földes László)
Status: Closed
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: 
Target version: next minor
ruby -v: ruby 1.9.3p260 (2012-08-09 revision 36669) [i686-linux]
Backport: 1.9.3: REQUIRED, 2.0.0: REQUIRED


Ruby 1.9.3 BigMath.exp accepts Fixnum for exponent but silently treats negative exponents as positive:
1.9.3p260 :009 > BigMath.exp(3, 10)
 => #<BigDecimal:9be2ce8,'0.2008553692E2',18(72)> 
1.9.3p260 :010 > BigMath.exp(-3, 10)
 => #<BigDecimal:9bd8e50,'0.2008553692E2',18(45)>

Converting the exponent parameter to BigDecimal solves the problem:
1.9.3p260 :011 > BigMath.exp(BigDecimal(-3), 10)
 => #<BigDecimal:9bd1420,'0.4978706837E-1',18(45)> 





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