mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
* unify the logic for exporting math functions from compiler-rt,
with the appropriate suffixes and prefixes.
- add all missing f128 and f80 exports. Functions with missing
implementations call other functions and have TODO comments.
- also add f16 functions
* move math functions from freestanding libc to compiler-rt (#7265)
* enable all the f128 and f80 code in the stage2 compiler and behavior
tests (#11161).
* update std lib to use builtins rather than `std.math`.
28 lines
843 B
Zig
28 lines
843 B
Zig
const math = @import("../math.zig");
|
|
|
|
/// Returns the nan representation for type T.
|
|
pub 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.
|
|
pub fn snan(comptime T: 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.
|
|
return switch (@typeInfo(T).Float.bits) {
|
|
16 => math.nan_u16,
|
|
32 => math.nan_u32,
|
|
64 => math.nan_u64,
|
|
80 => math.nan_u80,
|
|
128 => math.nan_u128,
|
|
else => @compileError("unreachable"),
|
|
};
|
|
}
|