Project

General

Profile

Actions

Bug #11995

closed

BigDecimal#power fails for some values

Added by dolzenko (Evgeniy Dolzhenko) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
[ruby-core:72879]

Description

$ irb -rbigdecimal

BigDecimal('-0.5').power(BigDecimal('0.2'))
Math::DomainError: Zero or negative argument for log

but

-0.5**0.2
=> -0.8705505632961241

The same is true for a few other exponent version I have tested. Is that feature or bug?

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Rejected

The latter is parsed as -(0.5**0.2).

$ ruby -e 'p (-0.5)**0.2'
(0.7042902001692478+0.5116967824803669i)

Float#** can result an imaginary number, but BigDecimal is only for real numbers.

Actions

Also available in: Atom PDF

Like0
Like0