aboutsummaryrefslogtreecommitdiff
path: root/std/math/isnan.zig
diff options
context:
space:
mode:
authorMarc Tiehuis <marctiehuis@gmail.com>2019-02-13 23:27:23 +1300
committerMarc Tiehuis <marctiehuis@gmail.com>2019-02-13 23:27:23 +1300
commitcf007e37b95db9faebf34c4c8f9b73aa20eb0672 (patch)
tree57ff58b87e4fffbfabbf83ce19e83405374ad1d4 /std/math/isnan.zig
parentbe861a85c8a1adc1f82c523136e6d6b18992c372 (diff)
downloadzig-cf007e37b95db9faebf34c4c8f9b73aa20eb0672.tar.gz
zig-cf007e37b95db9faebf34c4c8f9b73aa20eb0672.zip
Add f128 support for fabs, isinf, isnan, inf and nan functions
Diffstat (limited to 'std/math/isnan.zig')
-rw-r--r--std/math/isnan.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/std/math/isnan.zig b/std/math/isnan.zig
index 641da9e620..e8b03a1e34 100644
--- a/std/math/isnan.zig
+++ b/std/math/isnan.zig
@@ -18,6 +18,10 @@ pub fn isNan(x: var) bool {
const bits = @bitCast(u64, x);
return (bits & (maxInt(u64) >> 1)) > (u64(0x7FF) << 52);
},
+ f128 => {
+ const bits = @bitCast(u128, x);
+ return (bits & (maxInt(u128) >> 1)) > (u128(0x7FFF) << 112);
+ },
else => {
@compileError("isNan not implemented for " ++ @typeName(T));
},
@@ -34,7 +38,9 @@ test "math.isNan" {
expect(isNan(math.nan(f16)));
expect(isNan(math.nan(f32)));
expect(isNan(math.nan(f64)));
+ expect(isNan(math.nan(f128)));
expect(!isNan(f16(1.0)));
expect(!isNan(f32(1.0)));
expect(!isNan(f64(1.0)));
+ expect(!isNan(f128(1.0)));
}