diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-06 02:59:17 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-06 02:59:17 -0500 |
| commit | 38658a597bc22697c2038c21bdec9f04c9973eb8 (patch) | |
| tree | 4f52ec6d34bf1380750fcdb37c99e8b5d05c1762 /std | |
| parent | 2200c2de6f29845b2a41491fda663289fdc786d3 (diff) | |
| parent | dde7cc52d2f4780587b37604889c4568b8d79c62 (diff) | |
| download | zig-38658a597bc22697c2038c21bdec9f04c9973eb8.tar.gz zig-38658a597bc22697c2038c21bdec9f04c9973eb8.zip | |
Merge branch 'master' into llvm6
Diffstat (limited to 'std')
| -rw-r--r-- | std/math/expm1.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/std/math/expm1.zig b/std/math/expm1.zig index 10670c4cfc..f2d4d4f183 100644 --- a/std/math/expm1.zig +++ b/std/math/expm1.zig @@ -4,6 +4,7 @@ // - expm1(-inf) = -1 // - expm1(nan) = nan +const builtin = @import("builtin"); const std = @import("../index.zig"); const math = std.math; const assert = std.debug.assert; @@ -18,6 +19,7 @@ pub fn expm1(x: var) -> @typeOf(x) { } fn expm1_32(x_: f32) -> f32 { + @setFloatMode(this, builtin.FloatMode.Strict); const o_threshold: f32 = 8.8721679688e+01; const ln2_hi: f32 = 6.9313812256e-01; const ln2_lo: f32 = 9.0580006145e-06; @@ -122,7 +124,7 @@ fn expm1_32(x_: f32) -> f32 { } } - const twopk = @bitCast(f32, u32((0x7F + k) << 23)); + const twopk = @bitCast(f32, u32((0x7F +% k) << 23)); if (k < 0 or k > 56) { var y = x - e + 1.0; @@ -135,7 +137,7 @@ fn expm1_32(x_: f32) -> f32 { return y - 1.0; } - const uf = @bitCast(f32, u32(0x7F - k) << 23); + const uf = @bitCast(f32, u32(0x7F -% k) << 23); if (k < 23) { return (x - e + (1 - uf)) * twopk; } else { @@ -144,6 +146,7 @@ fn expm1_32(x_: f32) -> f32 { } fn expm1_64(x_: f64) -> f64 { + @setFloatMode(this, builtin.FloatMode.Strict); const o_threshold: f64 = 7.09782712893383973096e+02; const ln2_hi: f64 = 6.93147180369123816490e-01; const ln2_lo: f64 = 1.90821492927058770002e-10; @@ -251,7 +254,7 @@ fn expm1_64(x_: f64) -> f64 { } } - const twopk = @bitCast(f64, u64(0x3FF + k) << 52); + const twopk = @bitCast(f64, u64(0x3FF +% k) << 52); if (k < 0 or k > 56) { var y = x - e + 1.0; @@ -264,7 +267,7 @@ fn expm1_64(x_: f64) -> f64 { return y - 1.0; } - const uf = @bitCast(f64, u64(0x3FF - k) << 52); + const uf = @bitCast(f64, u64(0x3FF -% k) << 52); if (k < 20) { return (x - e + (1 - uf)) * twopk; } else { |
