zig/lib/std/math/isnan.zig
Andrew Kelley d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00

28 lines
800 B
Zig

const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
const maxInt = std.math.maxInt;
/// Returns whether x is a nan.
pub fn isNan(x: anytype) bool {
return x != x;
}
/// Returns whether x is a signalling nan.
pub fn isSignalNan(x: anytype) bool {
// Note: A signalling nan is identical to a standard nan right now but may have a different bit
// representation in the future when required.
return isNan(x);
}
test "math.isNan" {
try expect(isNan(math.nan(f16)));
try expect(isNan(math.nan(f32)));
try expect(isNan(math.nan(f64)));
try expect(isNan(math.nan(f128)));
try expect(!isNan(@as(f16, 1.0)));
try expect(!isNan(@as(f32, 1.0)));
try expect(!isNan(@as(f64, 1.0)));
try expect(!isNan(@as(f128, 1.0)));
}