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

RoundingMode of DefaultRoundingProvider hardcoded to HALF_EVEN #408

Open
jurriaan opened this issue Feb 27, 2024 · 1 comment
Open

RoundingMode of DefaultRoundingProvider hardcoded to HALF_EVEN #408

jurriaan opened this issue Feb 27, 2024 · 1 comment
Labels

Comments

@jurriaan
Copy link

I've set the org.javamoney.moneta.Money.defaults.roundingMode property to HALF_UP but noticed that the rounding using Monetary.getDefaultRounding() still used HALF_EVEN when rounding.

I think this is due to the DefaultRoundingProvider having the default roundingMode set to HALF_EVEN instead of using the configuration.

See:

Is this expected behavior?

@jurriaan jurriaan changed the title RoundingMode of default rounding hardcoded to HALF_EVEN RoundingMode of DefaultRoundingProvider hardcoded to HALF_EVEN Feb 27, 2024
@keilw keilw added the analysis label Mar 15, 2024
@kewne
Copy link
Contributor

kewne commented Apr 20, 2024

Is that property documented anywhere? As far as I can tell, the spec compliant way to get a rounding with a client defined rounding mode is:

RoundingQueryBuilder.of()
  .set(RoundingMode.class, RoundingMode.HALF_Up)
  .build();

Edit: Just looked at org.javamoney.moneta.Money.defaults.roundingMode. This should only affect rounding when Money instances are used, and even then it's only used when the result of an operation exceeds the precision.

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

3 participants