-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
documentationAddressing this item primarily involves writing docs / updating the websiteAddressing this item primarily involves writing docs / updating the website
Milestone
Description
BigDecimal has a wonky definition of equality, for example 1E2
is not equal to 100
in the sense that bigDecimalA.equals(bigDecimalB)
would return false
because they have different scales. Whilst we defer to BD's authors - that is evidently how they intend for equality to work - it's confusing in any case (not our fault), and often folks want to define equality as: Does it represent the same value?
There IS a way to accomplish this:
@EqualsAndHashCode.Include
private BigDecimal nameOfBigDecimalField() {
return nameOfBigDecimalField..stripTrailingZeros();
}
This should be named on the feature page of @EqualsAndHashCode
; probably in the smallprint, and including that snippet or at least a link to it.
See issue #1260 where @wacker confirmed that this 'trick' works.
Metadata
Metadata
Assignees
Labels
documentationAddressing this item primarily involves writing docs / updating the websiteAddressing this item primarily involves writing docs / updating the website