r/java • • Jun 14 '26

double, BigDecimal, or Fixed-Point?

https://blog.frankel.ch/bigdecimal-vs-double/
32 Upvotes

28 comments sorted by

View all comments

Show parent comment

1

u/gnahraf Jun 16 '26

No, BigDecimal's equals/hashCode implementations fulfill their contract just fine.

Ofc it is. My bad for suggesting otherwise, it was somewhat in jest.

Good to hear you agree with my canonicalizing BDs for hashing (SHA-256) purposes.

You draw a good distinction for BDs (2.0 and 2.00) re division.

In my app, btw, I only use fixed-precision operations: addition and multiplication by whole no.s, which makes it really just a shorthand for addition. (Not my area but I think technical jargon would be.. BDs are an additive group, not a field, since they lack multiplicative inverses.)