Project

General

Profile

Actions

Bug #6862

closed

BigMath.exp negative exponent

Added by karatedog (Földes László) over 11 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3p260 (2012-08-09 revision 36669) [i686-linux]
[ruby-core:47145]

Description

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)


Related issues 2 (0 open2 closed)

Related to Backport200 - Backport #8587: Back porting r41623Closednagachika (Tomoyuki Chikanaga)06/25/2013Actions
Related to Backport193 - Backport #8603: Back porting r41623Closedusa (Usaku NAKAMURA)06/25/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0