Module consts

Module consts 

Source
Expand description

Mathematical constants.

The constants have the maximum precision possible for a fixed-point number, and are rounded down at that precision.

§Examples

use fixed::consts;
use fixed::types::I4F28;
let tau = I4F28::from_num(consts::TAU);
println!("τ = 2π with eight binary places is {tau:.8b}");
assert_eq!(format!("{tau:.8b}"), "110.01001000");
println!("τ = 2π with eight decimal places is {tau:.8}");
assert_eq!(format!("{tau:.8}"), "6.28318531");

Constants§

CATALAN
Catalan’s constant = 0.915965…
E
Euler’s number, e = 2.71828…
FRAC_1_PHI
The golden ratio conjugate, Φ = 1/φ = 0.618033…
FRAC_1_PI
1/π = 0.318309…
FRAC_1_SQRT_2
1/√2 = 0.707106…
FRAC_1_SQRT_3
1/√3 = 0.577350…
FRAC_1_SQRT_2PI
1/√2π = 0.398942…
FRAC_1_SQRT_PI
1/√π = 0.564189…
FRAC_1_TAU
1/τ = 0.159154…
FRAC_2_PI
2/π = 0.636619…
FRAC_2_SQRT_PI
2/√π = 1.12837…
FRAC_2_TAU
2/τ = 0.318309…
FRAC_4_TAU
4/τ = 0.636619…
FRAC_PI_2
π/2 = 1.57079…
FRAC_PI_3
π/3 = 1.04719…
FRAC_PI_4
π/4 = 0.785398…
FRAC_PI_6
π/6 = 0.523598…
FRAC_PI_8
π/8 = 0.392699…
FRAC_TAU_2
τ/2 = 3.14159…
FRAC_TAU_3
τ/3 = 2.09439…
FRAC_TAU_4
τ/4 = 1.57079…
FRAC_TAU_6
τ/6 = 1.04719…
FRAC_TAU_8
τ/8 = 0.785398…
FRAC_TAU_12
τ/12 = 0.523598…
GAMMA
The Euler-Mascheroni constant, γ = 0.577215…
LN_2
ln 2 = 0.693147…
LN_10
ln 10 = 2.30258…
LOG2_10
log2 10 = 3.32192…
LOG2_E
log2 e = 1.44269…
LOG10_2
log10 2 = 0.301029…
LOG10_E
log10 e = 0.434294…
PHI
The golden ratio, φ = 1.61803…
PI
Archimedes’ constant, π = 3.14159…
SQRT_2
√2 = 1.41421…
SQRT_3
√3 = 1.73205…
SQRT_2PI
√2π = 2.50662…
SQRT_E
√e = 1.64872…
SQRT_PHI
√φ = 1.27201…
SQRT_PI
√π = 1.77245…
TAU
A turn, τ = 6.28318…