Skip to content

Commit

Permalink
Have equalWithin return true for same-sign infinities
Browse files Browse the repository at this point in the history
Consistent with aboutEqual, although I still think it feels weird
  • Loading branch information
ianmackenzie committed Mar 27, 2024
1 parent 4df9c0f commit d795f71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Float/Extra.elm
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ aboutEqual a b =
-}
equalWithin : Float -> Float -> Float -> Bool
equalWithin tolerance firstValue secondValue =
abs (secondValue - firstValue) <= tolerance
if isInfinite firstValue || isInfinite secondValue then
firstValue == secondValue

else
abs (secondValue - firstValue) <= tolerance



Expand Down

0 comments on commit d795f71

Please sign in to comment.