authorgravatar for shawn@git.icuShawn Landden <shawn@git.icu> 2019-04-05 08:47:52-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-05 11:03:57-04:00
logaecbd1892a871a2b046ceda9058c4132cd0cb392
tree144d7ccb352ca5a31bd9908359f36a3e019da9d1
parent1dc6751721a2fe9990ea8fab4eadc95a29f53304

Simplify math.isnan

We can just rely on the builtin behavior.

1 files changed, 1 insertions(+), 22 deletions(-)

std/math/isnan.zig+1-22
......@@ -4,28 +4,7 @@ const expect = std.testing.expect;
44const maxInt = std.math.maxInt;
55
66pub fn isNan(x: var) bool {
7 const T = @typeOf(x);
8 switch (T) {
9 f16 => {
10 const bits = @bitCast(u16, x);
11 return (bits & 0x7fff) > 0x7c00;
12 },
13 f32 => {
14 const bits = @bitCast(u32, x);
15 return bits & 0x7FFFFFFF > 0x7F800000;
16 },
17 f64 => {
18 const bits = @bitCast(u64, x);
19 return (bits & (maxInt(u64) >> 1)) > (u64(0x7FF) << 52);
20 },
21 f128 => {
22 const bits = @bitCast(u128, x);
23 return (bits & (maxInt(u128) >> 1)) > (u128(0x7FFF) << 112);
24 },
25 else => {
26 @compileError("isNan not implemented for " ++ @typeName(T));
27 },
28 }
7 return x != x;
298}
309
3110/// Note: A signalling nan is identical to a standard nan right now but may have a different bit