aboutsummaryrefslogtreecommitdiff
path: root/std/math/expm1.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-19 16:06:10 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-19 16:06:10 -0400
commitc7804277bf390eeba368e3565b2aff0cf96f86b0 (patch)
treecdf926acbc28a278ffeeb92552631a724c2da98d /std/math/expm1.zig
parent0b92d689d0e64164bb8908c807db9338d59c41ce (diff)
downloadzig-c7804277bf390eeba368e3565b2aff0cf96f86b0.tar.gz
zig-c7804277bf390eeba368e3565b2aff0cf96f86b0.zip
`@floatToInt` now has safety-checked undefined behavior
when the integer part does not fit in the destination integer type * Also fix incorrect safety triggered for integer casting an `i32` to a `u7`. closes #1138 * adds compiler-rt function: `__floatuntidf`
Diffstat (limited to 'std/math/expm1.zig')
-rw-r--r--std/math/expm1.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/std/math/expm1.zig b/std/math/expm1.zig
index 438e44ccce..6fa0194b32 100644
--- a/std/math/expm1.zig
+++ b/std/math/expm1.zig
@@ -20,6 +20,10 @@ pub fn expm1(x: var) @typeOf(x) {
fn expm1_32(x_: f32) f32 {
@setFloatMode(this, builtin.FloatMode.Strict);
+
+ if (math.isNan(x_))
+ return math.nan(f32);
+
const o_threshold: f32 = 8.8721679688e+01;
const ln2_hi: f32 = 6.9313812256e-01;
const ln2_lo: f32 = 9.0580006145e-06;
@@ -146,6 +150,10 @@ fn expm1_32(x_: f32) f32 {
fn expm1_64(x_: f64) f64 {
@setFloatMode(this, builtin.FloatMode.Strict);
+
+ if (math.isNan(x_))
+ return math.nan(f64);
+
const o_threshold: f64 = 7.09782712893383973096e+02;
const ln2_hi: f64 = 6.93147180369123816490e-01;
const ln2_lo: f64 = 1.90821492927058770002e-10;