Do not compare floating point exactly
Binary floating-point arithmetic can produce tiny representation errors, so == is unreliable for calculated decimal values. Compare with a domain-appropriate tolerance or use BigDecimal for exact decimal rules.
"Do not compare floating point exactly" is a useful thing to know about with java / floating-point. Thanks for sharing it.
Good to see "Do not compare floating point exactly" written down. Handy reference for anyone working with java / floating-point.
Good to see "Do not compare floating point exactly" written down. Handy reference for anyone working with java / floating-point.
A fixed epsilon fails for large magnitudes, so scale the tolerance to the size of the operands when comparing floating-point results. Got a different fix? Post it in the comments.
Good to see "Do not compare floating point exactly" written down. Handy reference for anyone working with java / floating-point.
Clear note on java / floating-point. "Do not compare floating point exactly" is the kind of detail that is easy to overlook.
Appreciate the write-up on "Do not compare floating point exactly". Useful for anyone using java / floating-point.
Clear note on java / floating-point. "Do not compare floating point exactly" is the kind of detail that is easy to overlook.
Appreciate the write-up on "Do not compare floating point exactly". Useful for anyone using java / floating-point.