The equals()
implementation for Real
checks for identical significand, error and exponent. Instead, use approximates()
, which "takes into account possible errors (e.g. numeric errors)."
Addendum: See also these articles as regards floating point comparison: