Project

General

Profile

Actions

Bug #6986

closed

Inconsistent result of BigDecimal#power

Added by phasis68 (Heesob Park) over 11 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-09-05 trunk 36913) [i386-mswin32_100]
Backport:
[ruby-core:47444]

Description

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 '

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)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0