Skip to content

BigDecimal#** shouldn't return Integer #345

Open
@tompng

Description

@tompng

BigDecimal#** is expect to return BigDecimal

/*  call-seq:
 *    self ** other -> bigdecimal
 *
 *  Returns the \BigDecimal value of +self+ raised to power +other+:
 * ...
 */
BigDecimal(123).power(10, 10)
# => 0.792594609605189126649e21 (BigDecimal) OK except too high precision
BigDecimal(123).power(10.5, 10)
# => 8790299449000000000000 (Integer) Questionable result

BigDecimal(123) ** BigDecimal('10.5')
#=> 0.879029945260967009185694434e22 BigDecimal, OK
# => 8790299449000000000000 (Integer) Definitely a bug.

BigMath.exp returning Integer is the cause.

# /* call-seq:
#  *   BigMath.exp(decimal, numeric)    -> BigDecimal

BigMath.exp(10, 5)
# => 22026 (Integer)
BigMath.exp(10, 6)
# => 0.220265e5 (BigDecimal)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions