aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-01-29 03:45:15 -0500
committerGitHub <noreply@github.com>2022-01-29 03:45:15 -0500
commit225910f9341fbc725ff5e0d2c653e29bc2f21cb8 (patch)
treeeac47d40ae555398c46e4ccdff9cace12eeabd3b /lib/std/math.zig
parent63ee6e662582ee75ac804eb1a4dbdf4457b8f2d0 (diff)
parenta0a71709bc2104c708f045fbb42c6247aff136ac (diff)
downloadzig-225910f9341fbc725ff5e0d2c653e29bc2f21cb8.tar.gz
zig-225910f9341fbc725ff5e0d2c653e29bc2f21cb8.zip
Merge pull request #10639 from Vexu/f80
Add f80
Diffstat (limited to 'lib/std/math.zig')
-rw-r--r--lib/std/math.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/std/math.zig b/lib/std/math.zig
index cb911b1263..59532d7ab2 100644
--- a/lib/std/math.zig
+++ b/lib/std/math.zig
@@ -43,7 +43,21 @@ pub const f128_max = @bitCast(f128, @as(u128, 0x7FFEFFFFFFFFFFFFFFFFFFFFFFFFFFFF
pub const f128_epsilon = @bitCast(f128, @as(u128, 0x3F8F0000000000000000000000000000));
pub const f128_toint = 1.0 / f128_epsilon;
+const F80Repr = if (@import("builtin").cpu.arch.endian() == .Little) extern struct {
+ fraction: u64,
+ exp: u16,
+} else extern struct {
+ exp: u16,
+ fraction: u64,
+};
+
// float.h details
+pub const f80_true_min = @ptrCast(*const f80, &F80Repr{ .fraction = 1, .exp = 0 }).*;
+pub const f80_min = @ptrCast(*const f80, &F80Repr{ .fraction = 0x8000000000000000, .exp = 1 }).*;
+pub const f80_max = @ptrCast(*const f80, &F80Repr{ .fraction = 0xFFFFFFFFFFFFFFFF, .exp = 0x7FFE }).*;
+pub const f80_epsilon = @ptrCast(*const f80, &F80Repr{ .fraction = 0x8000000000000000, .exp = 0x3FC0 }).*;
+pub const f80_toint = 1.0 / f80_epsilon;
+
pub const f64_true_min = 4.94065645841246544177e-324;
pub const f64_min = 2.2250738585072014e-308;
pub const f64_max = 1.79769313486231570815e+308;
@@ -91,6 +105,10 @@ pub const qnan_f64 = @bitCast(f64, qnan_u64);
pub const inf_u64 = @as(u64, 0x7FF << 52);
pub const inf_f64 = @bitCast(f64, inf_u64);
+pub const inf_f80 = @ptrCast(*const f80, &F80Repr{ .fraction = 0x8000000000000000, .exp = 0x7fff }).*;
+pub const nan_f80 = @ptrCast(*const f80, &F80Repr{ .fraction = 0xA000000000000000, .exp = 0x7fff }).*;
+pub const qnan_f80 = @ptrCast(*const f80, &F80Repr{ .fraction = 0xC000000000000000, .exp = 0x7fff }).*;
+
pub const nan_u128 = @as(u128, 0x7fff0000000000000000000000000001);
pub const nan_f128 = @bitCast(f128, nan_u128);