JavaMoney/jsr354-ri

Money.negate(MonetaryAmount) should return the negated amount with the original MonetaryContext

chrishaase opened this issue · 0 comments

The Money.class implements the MonetaryAmount interface that specifies a negate method. According to the JavaDocs, the negate function shall return " a MonetaryAmount whose value is -this, and whose scale is this.scale().". However, the Money.negate() function does currently not return this.MonetaryContext (including this.scale and this.precision). This behaviour is unexpected and different to the implementations of the multiply, divide, add and subtract methods in the Money class, which return a MonetaryAmount with the correct MonetaryContext. When the operation x.negate() is conducted this may lead to a different result than the operation x.multiply(-1). This is unexpected . Please make negate return a MonetaryAmount with this.MonetaryContext.