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

MaxScale on division #172

Closed
energister opened this issue Sep 29, 2017 · 1 comment
Closed

MaxScale on division #172

energister opened this issue Sep 29, 2017 · 1 comment
Labels
Milestone

Comments

@energister
Copy link

energister commented Sep 29, 2017

Is the test below correct? I expect quotient should have scale 2 because MonetaryContext of the dividend limits it.

@Test
public void maxScaleOnDivide() {
    MonetaryContext mc = MonetaryContextBuilder.of().setMaxScale(2).setPrecision(64).set(RoundingMode.CEILING).build();
    MonetaryAmount dividend = Monetary.getDefaultAmountFactory().setContext(mc).setNumber(100).setCurrency("EUR").create();
    MonetaryAmount quotient = dividend.divide(3);
    assertEquals(quotient.getContext().getMaxScale(), 2);
    assertEquals(quotient.getNumber().numberValue(BigDecimal.class), BigDecimal.valueOf(33.33));
}

At the moment it fails with:

Expected :2
Actual :-1

on first assertion and

Expected :33.33
Actual :33.33333333333333333333333333333333333333333333333333333333333334

on second.

@atsticks atsticks added the bug label Feb 11, 2018
@atsticks atsticks added this to the 1.2 milestone Feb 11, 2018
@atsticks
Copy link
Member

Fixed in 1.2

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