accounting-pattern icon indicating copy to clipboard operation
accounting-pattern copied to clipboard

Comparing `BigDecimal`s with different scales

Open pzygielo opened this issue 2 months ago • 0 comments

This causes failure:

AcceptanceTest.test:25 expected: <600> but was: <600.00>

in

https://github.com/grahambrooks/accounting-pattern/blob/da5d7f4a642ed1686fb40781db8c984080bb6baf/src/test/java/accounting/patterns/AcceptanceTest.java#L25

and later

https://github.com/grahambrooks/accounting-pattern/blob/da5d7f4a642ed1686fb40781db8c984080bb6baf/src/test/java/accounting/patterns/AcceptanceTest.java#L29

and then

https://github.com/grahambrooks/accounting-pattern/blob/da5d7f4a642ed1686fb40781db8c984080bb6baf/src/test/java/accounting/patterns/AcceptanceTest.java#L32

This is 7.4 Mistake 58: Comparing BigDecimals with different scales in 100 Java Mistakes and How to Avoid Them.

pzygielo avatar Oct 26 '25 13:10 pzygielo