/// Exponential, base *e* (f64) /// /// Calculate the exponential of `x`, that is, *e* raised to the power `x` /// (where *e* is the base of the natural system of logarithms, approximately 2.71828). #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pubfn exp(mut x: f64) -> f64 { let x1p1023 = f64::from_bits(0x7fe0000000000000); // 0x1p1023 === 2 ^ 1023 let x1p_149 = f64::from_bits(0x36a0000000000000); // 0x1p-149 === 2 ^ -149
let hi: f64; let lo: f64; let c: f64; let xx: f64; let y: f64; let k: i32; let sign: i32; letmut hx: u32;
hx = (x.to_bits() >> 32) as u32;
sign = (hx >> 31) as i32;
hx &= 0x7fffffff; /* high word of |x| */
/* special cases */ if hx >= 0x4086232b { /* if |x| >= 708.39... */ if x.is_nan() { return x;
} if x > 709.782712893383973096 { /* overflow if x!=inf */
x *= x1p1023; return x;
} if x < -708.39641853226410622 { /* underflow if x!=-inf */
force_eval!((-x1p_149 / x) as f32); if x < -745.13321910194110842 { return0.;
}
}
}
/* argument reduction */ if hx > 0x3fd62e42 { /* if |x| > 0.5 ln2 */ if hx >= 0x3ff0a2b2 { /* if |x| >= 1.5 ln2 */
k = (INVLN2 * x + i!(HALF, sign as usize)) as i32;
} else {
k = 1 - sign - sign;
}
hi = x - k as f64 * LN2HI; /* k*ln2hi is exact here */
lo = k as f64 * LN2LO;
x = hi - lo;
} elseif hx > 0x3e300000 { /* if |x| > 2**-28 */
k = 0;
hi = x;
lo = 0.;
} else { /* inexact if x!=0 */
force_eval!(x1p1023 + x); return1. + x;
}
/* x is now in primary range */
xx = x * x;
c = x - xx * (P1 + xx * (P2 + xx * (P3 + xx * (P4 + xx * P5))));
y = 1. + (x * c / (2. - c) - lo + hi); if k == 0 {
y
} else {
scalbn(y, k)
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.