diff options
| author | vassvik <mvassvik@gmail.com> | 2019-12-12 19:12:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-12 19:12:12 +0100 |
| commit | 2d97e1dee38857036aa15068dc70a2cb57e14381 (patch) | |
| tree | b5cbe4fc02236fb4990a95a8637c096e40800c91 /core/math | |
| parent | be2dfd42fdc8c7f4bdddbac8a5778dacd19df7f1 (diff) | |
Fix NaN checks in core:math.classify
Currently the classify procedures checks for NaNs using the check `x != x`, which is always false for NaNs and therefore that case is never entered. Using `!(x == x)` will work on the other hand.
Diffstat (limited to 'core/math')
| -rw-r--r-- | core/math/math.odin | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/math/math.odin b/core/math/math.odin index 583da00d0..4b011524d 100644 --- a/core/math/math.odin +++ b/core/math/math.odin @@ -469,7 +469,7 @@ classify_f32 :: proc(x: f32) -> Float_Class { return .Neg_Inf; } return .Inf; - case x != x: + case !(x == x): return .NaN; } @@ -493,7 +493,7 @@ classify_f64 :: proc(x: f64) -> Float_Class { return .Neg_Inf; } return .Inf; - case x != x: + case !(x == x): return .NaN; } u := transmute(u64)x; |