本文簡要介紹rust語言中 f64.exp_m1
的用法。
用法
pub fn exp_m1(self) -> f64
以準確的方式返回e^(self) - 1
,即使數字接近於零。
例子
let x = 1e-16_f64;
// for very small x, e^x is approximately 1 + x + x^2 / 2
let approx = x + x * x / 2.0;
let abs_difference = (x.exp_m1() - approx).abs();
assert!(abs_difference < 1e-20);
相關用法
- Rust f64.exp2用法及代碼示例
- Rust f64.exp用法及代碼示例
- Rust f64.signum用法及代碼示例
- Rust f64.sqrt用法及代碼示例
- Rust f64.is_finite用法及代碼示例
- Rust f64.round用法及代碼示例
- Rust f64.div_euclid用法及代碼示例
- Rust f64.hypot用法及代碼示例
- Rust f64.floor用法及代碼示例
- Rust f64.log用法及代碼示例
- Rust f64.asinh用法及代碼示例
- Rust f64.classify用法及代碼示例
- Rust f64.abs用法及代碼示例
- Rust f64.mul_add用法及代碼示例
- Rust f64.asin用法及代碼示例
- Rust f64.cbrt用法及代碼示例
- Rust f64.to_ne_bytes用法及代碼示例
- Rust f64.from_ne_bytes用法及代碼示例
- Rust f64.to_radians用法及代碼示例
- Rust f64.min用法及代碼示例
- Rust f64.atan用法及代碼示例
- Rust f64.is_nan用法及代碼示例
- Rust f64.max用法及代碼示例
- Rust f64.tanh用法及代碼示例
- Rust f64.cos用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 f64.exp_m1。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。