zig/lib/std/math/nan.zig
Andrew Kelley 087aedfa38 stage2: fix recent LLVM backend code
* std.math.snan: fix compilation error. Also make it and nan inline.
 * LLVM: use a proper enum type for float op instead of enum literal.
   Also various cleanups.
 * LLVM: use LLVMBuildVectorSplat for vector splat AIR instruction.
   - also the bindings had parameter order wrong
 * LLVM: additionally handle f16 lowering. For now all targets report OK
   but I think we will need to add some exceptions to this list.
2022-04-27 14:18:34 -07:00

20 lines
629 B
Zig

const math = @import("../math.zig");
/// Returns the nan representation for type T.
pub inline fn nan(comptime T: type) T {
return switch (@typeInfo(T).Float.bits) {
16 => math.nan_f16,
32 => math.nan_f32,
64 => math.nan_f64,
80 => math.nan_f80,
128 => math.nan_f128,
else => @compileError("unreachable"),
};
}
/// Returns the signalling nan representation for type T.
/// Note: A signalling nan is identical to a standard right now by may have a different bit
/// representation in the future when required.
pub inline fn snan(comptime T: type) T {
return nan(T);
}