movePoint() on 0 equivalent BigDecimal with negative exponent results in strange mantissa
Closed this issue · 0 comments
ericklaus-wf commented
Trying to simulate a negative scale (essentially, rounding to a tens place) requires code like
var zeroEquivalent:BigDecimal = BigDecimal.ZERO;
zeroEquivalent = zeroEquivalent.movePointLeft(1); //exp is now -1
zeroEquivalent = zeroEquivalent.setScale(0); //exp is now 0
zeroEquivalent = zeroEquivalent.movePointRight(1); //exp is 1 briefly; then a call to setScale(0) within movePoint() sets it to 0 again
However, the resulting zeroEquivalent
has a mantissa with two zeros, which leads to a weird toString result: "00". This differs from the Java BigDecimal implementation (see http://ideone.com/nWfcAf) as well as the original BigDecimal.as project.