Module fixed::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, types::I4F28};
let tau = I4F28::from_num(consts::TAU);
println!("τ = 2π with eight binary places is {:.8b}", tau);
assert_eq!(format!("{:.8b}", tau), "110.01001000");
println!("τ = 2π with eight decimal places is {:.8}", tau);
assert_eq!(format!("{:.8}", tau), "6.28318531");

Constants

Catalan’s constant = 0.915965…
Euler’s number, e = 2.71828…
The golden ratio conjugate, Φ = 1/φ = 0.618033…
1/π = 0.318309…
1/√2 = 0.707106…
1/√3 = 0.577350…
1/√π = 0.564189…
1/τ = 0.159154…
2/π = 0.636619…
2/√π = 1.12837…
2/τ = 0.318309…
4/τ = 0.636619…
π/2 = 1.57079…
π/3 = 1.04719…
π/4 = 0.785398…
π/6 = 0.523598…
π/8 = 0.392699…
τ/2 = 3.14159…
τ/3 = 2.09439…
τ/4 = 1.57079…
τ/6 = 1.04719…
τ/8 = 0.785398…
τ/12 = 0.523598…
The Euler-Mascheroni constant, γ = 0.577215…
ln 2 = 0.693147…
ln 10 = 2.30258…
log2 10 = 3.32192…
log2 e = 1.44269…
log10 2 = 0.301029…
log10 e = 0.434294…
The golden ratio, φ = 1.61803…
Archimedes’ constant, π = 3.14159…
√2 = 1.41421…
√3 = 1.73205…
√e = 1.64872…
√φ = 1.27201…
√π = 1.77245…
A turn, τ = 6.28318…