Project

General

Profile

Actions

Bug #8818

closed

BigDecimal#power

Added by dunric (David Unric) about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Target version:
ruby -v:
1.9.3p448, 2.0.0p247
[ruby-core:56802]

Description

=begin
Optional argument `prec' to BigDecimal#power does not alter result precision:

b=BigDecimal.new("1.034482758620689655172413793103448275862068965517241379310344827586206896551724"
=> #<BigDecimal:807a50,'0.1034482758 6206896551 7241379310 3448275862 0689655172 4137931034 4827586206 896551724E1',90(90)>
b.power(4,5)
=> #<BigDecimal:10bb958,'0.1145230820 5649522608 4116496837 8904565512 1514645522 7837309357 9496692262 3398620909 7657083959 5577995167 4087102580 1626227765 2022322103 9445425509 8044483027 2550796764 5108521224 2376085318 2822668783 6941752994 9199822984 0756361333 0486751376 0443160825 7538375836 4780052058 5170533352 3733848357 3007050945 8051326134 8742578974 976E1',324(513)>

expected result
=> #BigDecimal:110f508,'0.11453E1',18(27)
=end

Updated by mrkn (Kenta Murata) about 11 years ago

  • Category changed from core to ext
  • Assignee set to mrkn (Kenta Murata)
  • Target version set to 2.1.0
Actions #2

Updated by mrkn (Kenta Murata) almost 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43796.
David, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/bigdecimal/bigdecimal.c (BigDecimal_power): Round the result value.
    [Bug #8818] [ruby-core:56802]

  • test/bigdecimal/test_bigdecimal.rb: Add a test for the above fix.

Actions

Also available in: Atom PDF

Like0
Like0Like0