From 2d97e1dee38857036aa15068dc70a2cb57e14381 Mon Sep 17 00:00:00 2001 From: vassvik Date: Thu, 12 Dec 2019 19:12:12 +0100 Subject: [PATCH] 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. --- core/math/math.odin | 4 ++-- 1 file 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;