Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chrishaase opened this issue Jun 28, 2021 · 0 comments
Labels
Milestone

Comments

@chrishaase
Copy link

chrishaase commented Jun 28, 2021

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.

@keilw keilw added the analysis label Feb 24, 2023
@keilw keilw added this to the 1.5 milestone Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants