Bug #9214
closedBigDecimal: BigDecimal() and to_d does not always make currect for -0.0
Description
BigDecimal does not always works currect for -0.0
BigDecimal("-0.0") => #BigDecimal:1065c88,'-0.0',9(18)
BigDecimal(-0.0,0) => #BigDecimal:10617a0,'0.0',9(27)
(-0.0).to_d => #BigDecimal:10268d0,'0.0',9(36)
i think the problem is related to #8265 because currently there is no nice way to check for -0.0 because equal? can not check it
Updated by mrkn (Kenta Murata) over 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44021.
Hans, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
-
ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec):
treat 0.0 and -0.0 of floating-point numbers specially for an optimization
and to correctly propagate its signbit to the result.
[Bug #9214] [ruby-core:58858] -
test/bigdecimal/test_bigdecimal.rb: add tests case for the above change.
-
test/bigdecimal/test_bigdecimal_util.rb: ditto.