Actions
Bug #18677
openBigDecimal#power (**) returns FloatDomainError when passing an infinite parameter
Bug #18677: BigDecimal#power (**) returns FloatDomainError when passing an infinite parameter
ruby -v:
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin21]
Description
Example:
> BigDecimal(10) ** BigDecimal("Infinity") FloatDomainError: Computation results in 'Infinity' Maybe:
require "bigdecimal/util" class BigDecimal < Numeric def **(other) if other.infinite? == 1 if self > 1 BigDecimal::INFINITY elsif self == 1 self elsif self >= 0 BigDecimal(0) else power(other) end else power(other) end end end def puts_and_eval(string) puts string p eval(string) end puts_and_eval "10 ** BigDecimal::INFINITY" puts_and_eval "1 ** BigDecimal::INFINITY" puts_and_eval "0.1 ** BigDecimal::INFINITY" puts_and_eval "0 ** BigDecimal::INFINITY" puts_and_eval "-1 ** BigDecimal::INFINITY" Seems like ruby is doing very different things from math though
Actions