#[repr(transparent)]pub struct Float<T>(pub T);
Expand description
Provides comprehensive floating-point operations for T
, most of them const.
See also the ExtFloat
and ExtFloatConst
traits.
§Methods
TODO
§Features
It depends on having any _float_f[32|64]
features enabled.
The wrapper leverages std
or libm
if enabled, otherwise implements fallbacks.
It also favors std
style for method’s names, but changes a few like minimum
for min_nan
and maximum
for max_nan
, for consistency.
If both the libm
and std
features are enabled the libm
functions will
be used, since it contains more functions, namely:
Tuple Fields§
§0: T
Implementations§
Source§impl Float<f32>
§Mathematical constants
impl Float<f32>
§Mathematical constants
See ExtFloatConst
.
Sourcepub const NEG_INFINITY: Float<f32>
pub const NEG_INFINITY: Float<f32>
Negative infinity (-∞).
Sourcepub const EPSILON: Float<f32>
pub const EPSILON: Float<f32>
Machine epsilon value.
This is the smallest difference detectable between 1.0 and the next representable number in the floating-point format.
Sourcepub const LOW_MARGIN: Float<f32>
pub const LOW_MARGIN: Float<f32>
Allows for minimal deviation; use for high precision needs..
Sourcepub const MEDIUM_MARGIN: Float<f32>
pub const MEDIUM_MARGIN: Float<f32>
Accommodates moderate deviation; balances precision and flexibility.
Sourcepub const HIGH_MARGIN: Float<f32>
pub const HIGH_MARGIN: Float<f32>
Permits generous deviation; suitable for less precise scenarios.
Sourcepub const MANTISSA_DIGITS: u32 = 24u32
pub const MANTISSA_DIGITS: u32 = 24u32
Number of significant digits in base 2.
Sourcepub const MIN_POSITIVE: Float<f32>
pub const MIN_POSITIVE: Float<f32>
Smallest positive normal value.
Sourcepub const MIN_EXP: i32 = -125i32
pub const MIN_EXP: i32 = -125i32
One greater than the minimum possible normal power of 2 exponent.
Sourcepub const MIN_10_EXP: i32 = -37i32
pub const MIN_10_EXP: i32 = -37i32
Minimum x for which 10x is normal.
Sourcepub const MAX_10_EXP: i32 = 38i32
pub const MAX_10_EXP: i32 = 38i32
Maximum x for which 10x is normal.
Sourcepub const PI: Float<f32>
pub const PI: Float<f32>
$ π = \frac{1}{2} τ = 180º $
(A000796)
≈ 3.14159265…
The ratio of the circumference to the diameter, a half-turn.
Sourcepub const FRAC_1_SQRT_PI: Float<f32>
pub const FRAC_1_SQRT_PI: Float<f32>
$ 1/\sqrt{π} = 1/\sqrt{τ/2} $
(A087197)
≈ 0.56418958…
Sourcepub const FRAC_1_SQRT_2PI: Float<f32>
pub const FRAC_1_SQRT_2PI: Float<f32>
$ 1/\sqrt{2π} = 1/\sqrt{τ} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_SQRT_PI: Float<f32>
pub const FRAC_2_SQRT_PI: Float<f32>
$ 2/\sqrt{π} $
(A190732)
≈ 1.12837916…
Sourcepub const TAU: Float<f32>
pub const TAU: Float<f32>
$ τ = 2π = 360º $
(A019692)
≈ 6.28318530…
The ratio of the circumference to the radius, a full-turn.
Sourcepub const FRAC_TAU_2: Float<f32> = Self::PI
pub const FRAC_TAU_2: Float<f32> = Self::PI
$ τ/2 = π = 180º $
(A000796)
≈ 3.14159265…
Sourcepub const FRAC_TAU_3: Float<f32>
pub const FRAC_TAU_3: Float<f32>
$ τ/3 = 2π/3 = 120º $
(A019693)
≈ 2.09439510…
Sourcepub const FRAC_TAU_4: Float<f32> = Self::FRAC_PI_2
pub const FRAC_TAU_4: Float<f32> = Self::FRAC_PI_2
$ τ/4 = π/2 = 90º $
(A019693)
≈ 1.57079632…
Sourcepub const FRAC_TAU_5: Float<f32>
pub const FRAC_TAU_5: Float<f32>
$ τ/5 = 2π/5 = 72º $
(A019694)
≈ 1.25663706…
Sourcepub const FRAC_TAU_6: Float<f32> = Self::FRAC_PI_3
pub const FRAC_TAU_6: Float<f32> = Self::FRAC_PI_3
$ τ/6 = π/3 = 60º $
(A019670)
≈ 1.04719755…
Sourcepub const FRAC_TAU_8: Float<f32> = Self::FRAC_PI_4
pub const FRAC_TAU_8: Float<f32> = Self::FRAC_PI_4
$ τ/8 = π/4 = 45º $
(A003881)
≈ 0.78539816…
Sourcepub const FRAC_TAU_9: Float<f32>
pub const FRAC_TAU_9: Float<f32>
$ τ/9 = 2π/9 = 40º $
(A019696)
≈ 0.69813170…
Sourcepub const FRAC_TAU_12: Float<f32> = Self::FRAC_PI_6
pub const FRAC_TAU_12: Float<f32> = Self::FRAC_PI_6
$ τ/12 = π/6 = 30º $
(A019673)
≈ 0.52359877…
Sourcepub const FRAC_TAU_16: Float<f32> = Self::FRAC_PI_8
pub const FRAC_TAU_16: Float<f32> = Self::FRAC_PI_8
$ τ/16 = π/8 = 22.5º $
(A019675)
≈ 0.39269908…
Sourcepub const FRAC_TAU_24: Float<f32>
pub const FRAC_TAU_24: Float<f32>
$ τ/24 = π/12 = 15º $
(A019679)
≈ 0.26179938…
Sourcepub const FRAC_TAU_72: Float<f32>
pub const FRAC_TAU_72: Float<f32>
$ τ/72 = π/36 = 5º $
≈ 0.08726646…
Sourcepub const FRAC_360_TAU: Float<f32>
pub const FRAC_360_TAU: Float<f32>
$ 360/τ = 180/π $
(A072097)
≈ 57.2957795…
Sourcepub const FRAC_1_TAU: Float<f32>
pub const FRAC_1_TAU: Float<f32>
$ 1/τ = 1/2π $
(A086201)
≈ 0.15915494…
Sourcepub const FRAC_1_SQRT_TAU: Float<f32>
pub const FRAC_1_SQRT_TAU: Float<f32>
$ 1/\sqrt{τ} = 1/\sqrt{2π} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_TAU: Float<f32> = Self::FRAC_1_PI
pub const FRAC_2_TAU: Float<f32> = Self::FRAC_1_PI
$ 2/τ = 1/π $
(A049541)
≈ 0.31830988…
Sourcepub const FRAC_2_SQRT_TAU: Float<f32>
pub const FRAC_2_SQRT_TAU: Float<f32>
$ 2/\sqrt{τ} = \sqrt{2/π} $
(A076668)
≈ 0.79788456…
Sourcepub const ARC_DEGREE: Float<f32>
pub const ARC_DEGREE: Float<f32>
Sourcepub const ARC_MINUTE: Float<f32>
pub const ARC_MINUTE: Float<f32>
$ τ/(360*60) = 1’ $ arc minute
(wikipedia)
≈ 0.00029088…
Sourcepub const ARC_SECOND: Float<f32>
pub const ARC_SECOND: Float<f32>
$ τ/(360 * 60 * 60) = 1’’ $ arc second
(wikipedia)
≈ 0.00000484…
Sourcepub const PHI: Float<f32>
pub const PHI: Float<f32>
$ φ = (1+\sqrt{5})/2 $
(A001622)
≈ 1.61803398…
The golden ratio.
Continued fraction: $ [1;1,1,1,…] $
Sourcepub const NEG_FRAC_1_PHI: Float<f32>
pub const NEG_FRAC_1_PHI: Float<f32>
$ -1/φ = 1-φ $
≈ -0.61803398…
The negative reciprocal of φ and its conjugate in $ x^2-x-1 $.
Sourcepub const FRAC_1_SQRT_PHI: Float<f32>
pub const FRAC_1_SQRT_PHI: Float<f32>
$ 1/\sqrt{φ} = \sqrt{φ/φ^2} = \sqrt{φ^2-2} $
(A197762)
≈ 0.78615137…
Sourcepub const TRIBONACCI: Float<f32>
pub const TRIBONACCI: Float<f32>
(A058265)
≈ 1.83928675…
The tribonacci constant.
Sourcepub const FRAC_1_SQRT_2: Float<f32>
pub const FRAC_1_SQRT_2: Float<f32>
Sourcepub const FRAC_1_SQRT_3: Float<f32>
pub const FRAC_1_SQRT_3: Float<f32>
$ 1/\sqrt{3} = \sqrt{1/3} $
(A020760,
≈ 0.57735026…
Sourcepub const FRAC_1_CBRT_3: Float<f32>
pub const FRAC_1_CBRT_3: Float<f32>
$ 1/\sqrt[\small 3]{3} = (\normalsize\frac{1}{3})^{\small\frac{1}{3}} $
(A072365)
≈ 0.69336127…
Sourcepub const E: Float<f32>
pub const E: Float<f32>
$ e $
(A001113)
≈ 2.71828182…
The Euler number or Napier’s constant.
Continuous fraction: $ [2;1,2,1,1,4,1,1,6,1,…,1,2n,1,…] $
Source§impl Float<f64>
§Mathematical constants
impl Float<f64>
§Mathematical constants
See ExtFloatConst
.
Sourcepub const NEG_INFINITY: Float<f64>
pub const NEG_INFINITY: Float<f64>
Negative infinity (-∞).
Sourcepub const EPSILON: Float<f64>
pub const EPSILON: Float<f64>
Machine epsilon value.
This is the smallest difference detectable between 1.0 and the next representable number in the floating-point format.
Sourcepub const LOW_MARGIN: Float<f64>
pub const LOW_MARGIN: Float<f64>
Allows for minimal deviation; use for high precision needs..
Sourcepub const MEDIUM_MARGIN: Float<f64>
pub const MEDIUM_MARGIN: Float<f64>
Accommodates moderate deviation; balances precision and flexibility.
Sourcepub const HIGH_MARGIN: Float<f64>
pub const HIGH_MARGIN: Float<f64>
Permits generous deviation; suitable for less precise scenarios.
Sourcepub const MANTISSA_DIGITS: u32 = 53u32
pub const MANTISSA_DIGITS: u32 = 53u32
Number of significant digits in base 2.
Sourcepub const MIN_POSITIVE: Float<f64>
pub const MIN_POSITIVE: Float<f64>
Smallest positive normal value.
Sourcepub const MIN_EXP: i32 = -1_021i32
pub const MIN_EXP: i32 = -1_021i32
One greater than the minimum possible normal power of 2 exponent.
Sourcepub const MIN_10_EXP: i32 = -307i32
pub const MIN_10_EXP: i32 = -307i32
Minimum x for which 10x is normal.
Sourcepub const MAX_10_EXP: i32 = 308i32
pub const MAX_10_EXP: i32 = 308i32
Maximum x for which 10x is normal.
Sourcepub const PI: Float<f64>
pub const PI: Float<f64>
$ π = \frac{1}{2} τ = 180º $
(A000796)
≈ 3.14159265…
The ratio of the circumference to the diameter, a half-turn.
Sourcepub const FRAC_1_SQRT_PI: Float<f64>
pub const FRAC_1_SQRT_PI: Float<f64>
$ 1/\sqrt{π} = 1/\sqrt{τ/2} $
(A087197)
≈ 0.56418958…
Sourcepub const FRAC_1_SQRT_2PI: Float<f64>
pub const FRAC_1_SQRT_2PI: Float<f64>
$ 1/\sqrt{2π} = 1/\sqrt{τ} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_SQRT_PI: Float<f64>
pub const FRAC_2_SQRT_PI: Float<f64>
$ 2/\sqrt{π} $
(A190732)
≈ 1.12837916…
Sourcepub const TAU: Float<f64>
pub const TAU: Float<f64>
$ τ = 2π = 360º $
(A019692)
≈ 6.28318530…
The ratio of the circumference to the radius, a full-turn.
Sourcepub const FRAC_TAU_2: Float<f64> = Self::PI
pub const FRAC_TAU_2: Float<f64> = Self::PI
$ τ/2 = π = 180º $
(A000796)
≈ 3.14159265…
Sourcepub const FRAC_TAU_3: Float<f64>
pub const FRAC_TAU_3: Float<f64>
$ τ/3 = 2π/3 = 120º $
(A019693)
≈ 2.09439510…
Sourcepub const FRAC_TAU_4: Float<f64> = Self::FRAC_PI_2
pub const FRAC_TAU_4: Float<f64> = Self::FRAC_PI_2
$ τ/4 = π/2 = 90º $
(A019693)
≈ 1.57079632…
Sourcepub const FRAC_TAU_5: Float<f64>
pub const FRAC_TAU_5: Float<f64>
$ τ/5 = 2π/5 = 72º $
(A019694)
≈ 1.25663706…
Sourcepub const FRAC_TAU_6: Float<f64> = Self::FRAC_PI_3
pub const FRAC_TAU_6: Float<f64> = Self::FRAC_PI_3
$ τ/6 = π/3 = 60º $
(A019670)
≈ 1.04719755…
Sourcepub const FRAC_TAU_8: Float<f64> = Self::FRAC_PI_4
pub const FRAC_TAU_8: Float<f64> = Self::FRAC_PI_4
$ τ/8 = π/4 = 45º $
(A003881)
≈ 0.78539816…
Sourcepub const FRAC_TAU_9: Float<f64>
pub const FRAC_TAU_9: Float<f64>
$ τ/9 = 2π/9 = 40º $
(A019696)
≈ 0.69813170…
Sourcepub const FRAC_TAU_12: Float<f64> = Self::FRAC_PI_6
pub const FRAC_TAU_12: Float<f64> = Self::FRAC_PI_6
$ τ/12 = π/6 = 30º $
(A019673)
≈ 0.52359877…
Sourcepub const FRAC_TAU_16: Float<f64> = Self::FRAC_PI_8
pub const FRAC_TAU_16: Float<f64> = Self::FRAC_PI_8
$ τ/16 = π/8 = 22.5º $
(A019675)
≈ 0.39269908…
Sourcepub const FRAC_TAU_24: Float<f64>
pub const FRAC_TAU_24: Float<f64>
$ τ/24 = π/12 = 15º $
(A019679)
≈ 0.26179938…
Sourcepub const FRAC_TAU_72: Float<f64>
pub const FRAC_TAU_72: Float<f64>
$ τ/72 = π/36 = 5º $
≈ 0.08726646…
Sourcepub const FRAC_360_TAU: Float<f64>
pub const FRAC_360_TAU: Float<f64>
$ 360/τ = 180/π $
(A072097)
≈ 57.2957795…
Sourcepub const FRAC_1_TAU: Float<f64>
pub const FRAC_1_TAU: Float<f64>
$ 1/τ = 1/2π $
(A086201)
≈ 0.15915494…
Sourcepub const FRAC_1_SQRT_TAU: Float<f64>
pub const FRAC_1_SQRT_TAU: Float<f64>
$ 1/\sqrt{τ} = 1/\sqrt{2π} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_TAU: Float<f64> = Self::FRAC_1_PI
pub const FRAC_2_TAU: Float<f64> = Self::FRAC_1_PI
$ 2/τ = 1/π $
(A049541)
≈ 0.31830988…
Sourcepub const FRAC_2_SQRT_TAU: Float<f64>
pub const FRAC_2_SQRT_TAU: Float<f64>
$ 2/\sqrt{τ} = \sqrt{2/π} $
(A076668)
≈ 0.79788456…
Sourcepub const ARC_DEGREE: Float<f64>
pub const ARC_DEGREE: Float<f64>
Sourcepub const ARC_MINUTE: Float<f64>
pub const ARC_MINUTE: Float<f64>
$ τ/(360*60) = 1’ $ arc minute
(wikipedia)
≈ 0.00029088…
Sourcepub const ARC_SECOND: Float<f64>
pub const ARC_SECOND: Float<f64>
$ τ/(360 * 60 * 60) = 1’’ $ arc second
(wikipedia)
≈ 0.00000484…
Sourcepub const PHI: Float<f64>
pub const PHI: Float<f64>
$ φ = (1+\sqrt{5})/2 $
(A001622)
≈ 1.61803398…
The golden ratio.
Continued fraction: $ [1;1,1,1,…] $
Sourcepub const NEG_FRAC_1_PHI: Float<f64>
pub const NEG_FRAC_1_PHI: Float<f64>
$ -1/φ = 1-φ $
≈ -0.61803398…
The negative reciprocal of φ and its conjugate in $ x^2-x-1 $.
Sourcepub const FRAC_1_SQRT_PHI: Float<f64>
pub const FRAC_1_SQRT_PHI: Float<f64>
$ 1/\sqrt{φ} = \sqrt{φ/φ^2} = \sqrt{φ^2-2} $
(A197762)
≈ 0.78615137…
Sourcepub const TRIBONACCI: Float<f64>
pub const TRIBONACCI: Float<f64>
(A058265)
≈ 1.83928675…
The tribonacci constant.
Sourcepub const FRAC_1_SQRT_2: Float<f64>
pub const FRAC_1_SQRT_2: Float<f64>
Sourcepub const FRAC_1_SQRT_3: Float<f64>
pub const FRAC_1_SQRT_3: Float<f64>
$ 1/\sqrt{3} = \sqrt{1/3} $
(A020760,
≈ 0.57735026…
Sourcepub const FRAC_1_CBRT_3: Float<f64>
pub const FRAC_1_CBRT_3: Float<f64>
$ 1/\sqrt[\small 3]{3} = (\normalsize\frac{1}{3})^{\small\frac{1}{3}} $
(A072365)
≈ 0.69336127…
Sourcepub const E: Float<f64>
pub const E: Float<f64>
$ e $
(A001113)
≈ 2.71828182…
The Euler number or Napier’s constant.
Continuous fraction: $ [2;1,2,1,1,4,1,1,6,1,…,1,2n,1,…] $
Source§impl Float<f16>
§Mathematical constants
impl Float<f16>
§Mathematical constants
See ExtFloatConst
.
Sourcepub const NEG_INFINITY: Float<f16>
pub const NEG_INFINITY: Float<f16>
Negative infinity (-∞).
Sourcepub const EPSILON: Float<f16>
pub const EPSILON: Float<f16>
Machine epsilon value.
This is the smallest difference detectable between 1.0 and the next representable number in the floating-point format.
Sourcepub const LOW_MARGIN: Float<f16>
pub const LOW_MARGIN: Float<f16>
Allows for minimal deviation; use for high precision needs..
Sourcepub const MEDIUM_MARGIN: Float<f16>
pub const MEDIUM_MARGIN: Float<f16>
Accommodates moderate deviation; balances precision and flexibility.
Sourcepub const HIGH_MARGIN: Float<f16>
pub const HIGH_MARGIN: Float<f16>
Permits generous deviation; suitable for less precise scenarios.
Sourcepub const MANTISSA_DIGITS: u32 = 11u32
pub const MANTISSA_DIGITS: u32 = 11u32
Number of significant digits in base 2.
Sourcepub const MIN_POSITIVE: Float<f16>
pub const MIN_POSITIVE: Float<f16>
Smallest positive normal value.
Sourcepub const MIN_EXP: i32 = -13i32
pub const MIN_EXP: i32 = -13i32
One greater than the minimum possible normal power of 2 exponent.
Sourcepub const MIN_10_EXP: i32 = -4i32
pub const MIN_10_EXP: i32 = -4i32
Minimum x for which 10x is normal.
Sourcepub const MAX_10_EXP: i32 = 4i32
pub const MAX_10_EXP: i32 = 4i32
Maximum x for which 10x is normal.
Sourcepub const PI: Float<f16>
pub const PI: Float<f16>
$ π = \frac{1}{2} τ = 180º $
(A000796)
≈ 3.14159265…
The ratio of the circumference to the diameter, a half-turn.
Sourcepub const FRAC_1_SQRT_PI: Float<f16>
pub const FRAC_1_SQRT_PI: Float<f16>
$ 1/\sqrt{π} = 1/\sqrt{τ/2} $
(A087197)
≈ 0.56418958…
Sourcepub const FRAC_1_SQRT_2PI: Float<f16>
pub const FRAC_1_SQRT_2PI: Float<f16>
$ 1/\sqrt{2π} = 1/\sqrt{τ} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_SQRT_PI: Float<f16>
pub const FRAC_2_SQRT_PI: Float<f16>
$ 2/\sqrt{π} $
(A190732)
≈ 1.12837916…
Sourcepub const TAU: Float<f16>
pub const TAU: Float<f16>
$ τ = 2π = 360º $
(A019692)
≈ 6.28318530…
The ratio of the circumference to the radius, a full-turn.
Sourcepub const FRAC_TAU_2: Float<f16> = Self::PI
pub const FRAC_TAU_2: Float<f16> = Self::PI
$ τ/2 = π = 180º $
(A000796)
≈ 3.14159265…
Sourcepub const FRAC_TAU_3: Float<f16>
pub const FRAC_TAU_3: Float<f16>
$ τ/3 = 2π/3 = 120º $
(A019693)
≈ 2.09439510…
Sourcepub const FRAC_TAU_4: Float<f16> = Self::FRAC_PI_2
pub const FRAC_TAU_4: Float<f16> = Self::FRAC_PI_2
$ τ/4 = π/2 = 90º $
(A019693)
≈ 1.57079632…
Sourcepub const FRAC_TAU_5: Float<f16>
pub const FRAC_TAU_5: Float<f16>
$ τ/5 = 2π/5 = 72º $
(A019694)
≈ 1.25663706…
Sourcepub const FRAC_TAU_6: Float<f16> = Self::FRAC_PI_3
pub const FRAC_TAU_6: Float<f16> = Self::FRAC_PI_3
$ τ/6 = π/3 = 60º $
(A019670)
≈ 1.04719755…
Sourcepub const FRAC_TAU_8: Float<f16> = Self::FRAC_PI_4
pub const FRAC_TAU_8: Float<f16> = Self::FRAC_PI_4
$ τ/8 = π/4 = 45º $
(A003881)
≈ 0.78539816…
Sourcepub const FRAC_TAU_9: Float<f16>
pub const FRAC_TAU_9: Float<f16>
$ τ/9 = 2π/9 = 40º $
(A019696)
≈ 0.69813170…
Sourcepub const FRAC_TAU_12: Float<f16> = Self::FRAC_PI_6
pub const FRAC_TAU_12: Float<f16> = Self::FRAC_PI_6
$ τ/12 = π/6 = 30º $
(A019673)
≈ 0.52359877…
Sourcepub const FRAC_TAU_16: Float<f16> = Self::FRAC_PI_8
pub const FRAC_TAU_16: Float<f16> = Self::FRAC_PI_8
$ τ/16 = π/8 = 22.5º $
(A019675)
≈ 0.39269908…
Sourcepub const FRAC_TAU_24: Float<f16>
pub const FRAC_TAU_24: Float<f16>
$ τ/24 = π/12 = 15º $
(A019679)
≈ 0.26179938…
Sourcepub const FRAC_TAU_72: Float<f16>
pub const FRAC_TAU_72: Float<f16>
$ τ/72 = π/36 = 5º $
≈ 0.08726646…
Sourcepub const FRAC_360_TAU: Float<f16>
pub const FRAC_360_TAU: Float<f16>
$ 360/τ = 180/π $
(A072097)
≈ 57.2957795…
Sourcepub const FRAC_1_TAU: Float<f16>
pub const FRAC_1_TAU: Float<f16>
$ 1/τ = 1/2π $
(A086201)
≈ 0.15915494…
Sourcepub const FRAC_1_SQRT_TAU: Float<f16>
pub const FRAC_1_SQRT_TAU: Float<f16>
$ 1/\sqrt{τ} = 1/\sqrt{2π} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_TAU: Float<f16> = Self::FRAC_1_PI
pub const FRAC_2_TAU: Float<f16> = Self::FRAC_1_PI
$ 2/τ = 1/π $
(A049541)
≈ 0.31830988…
Sourcepub const FRAC_2_SQRT_TAU: Float<f16>
pub const FRAC_2_SQRT_TAU: Float<f16>
$ 2/\sqrt{τ} = \sqrt{2/π} $
(A076668)
≈ 0.79788456…
Sourcepub const ARC_DEGREE: Float<f16>
pub const ARC_DEGREE: Float<f16>
Sourcepub const ARC_MINUTE: Float<f16>
pub const ARC_MINUTE: Float<f16>
$ τ/(360*60) = 1’ $ arc minute
(wikipedia)
≈ 0.00029088…
Sourcepub const ARC_SECOND: Float<f16>
pub const ARC_SECOND: Float<f16>
$ τ/(360 * 60 * 60) = 1’’ $ arc second
(wikipedia)
≈ 0.00000484…
Sourcepub const PHI: Float<f16>
pub const PHI: Float<f16>
$ φ = (1+\sqrt{5})/2 $
(A001622)
≈ 1.61803398…
The golden ratio.
Continued fraction: $ [1;1,1,1,…] $
Sourcepub const NEG_FRAC_1_PHI: Float<f16>
pub const NEG_FRAC_1_PHI: Float<f16>
$ -1/φ = 1-φ $
≈ -0.61803398…
The negative reciprocal of φ and its conjugate in $ x^2-x-1 $.
Sourcepub const FRAC_1_SQRT_PHI: Float<f16>
pub const FRAC_1_SQRT_PHI: Float<f16>
$ 1/\sqrt{φ} = \sqrt{φ/φ^2} = \sqrt{φ^2-2} $
(A197762)
≈ 0.78615137…
Sourcepub const TRIBONACCI: Float<f16>
pub const TRIBONACCI: Float<f16>
(A058265)
≈ 1.83928675…
The tribonacci constant.
Sourcepub const FRAC_1_SQRT_2: Float<f16>
pub const FRAC_1_SQRT_2: Float<f16>
Sourcepub const FRAC_1_SQRT_3: Float<f16>
pub const FRAC_1_SQRT_3: Float<f16>
$ 1/\sqrt{3} = \sqrt{1/3} $
(A020760,
≈ 0.57735026…
Sourcepub const FRAC_1_CBRT_3: Float<f16>
pub const FRAC_1_CBRT_3: Float<f16>
$ 1/\sqrt[\small 3]{3} = (\normalsize\frac{1}{3})^{\small\frac{1}{3}} $
(A072365)
≈ 0.69336127…
Sourcepub const E: Float<f16>
pub const E: Float<f16>
$ e $
(A001113)
≈ 2.71828182…
The Euler number or Napier’s constant.
Continuous fraction: $ [2;1,2,1,1,4,1,1,6,1,…,1,2n,1,…] $
Source§impl Float<f128>
§Mathematical constants
impl Float<f128>
§Mathematical constants
See ExtFloatConst
.
Sourcepub const NEG_INFINITY: Float<f128>
pub const NEG_INFINITY: Float<f128>
Negative infinity (-∞).
Sourcepub const EPSILON: Float<f128>
pub const EPSILON: Float<f128>
Machine epsilon value.
This is the smallest difference detectable between 1.0 and the next representable number in the floating-point format.
Sourcepub const LOW_MARGIN: Float<f128>
pub const LOW_MARGIN: Float<f128>
Allows for minimal deviation; use for high precision needs..
Sourcepub const MEDIUM_MARGIN: Float<f128>
pub const MEDIUM_MARGIN: Float<f128>
Accommodates moderate deviation; balances precision and flexibility.
Sourcepub const HIGH_MARGIN: Float<f128>
pub const HIGH_MARGIN: Float<f128>
Permits generous deviation; suitable for less precise scenarios.
Sourcepub const MANTISSA_DIGITS: u32 = 113u32
pub const MANTISSA_DIGITS: u32 = 113u32
Number of significant digits in base 2.
Sourcepub const MIN_POSITIVE: Float<f128>
pub const MIN_POSITIVE: Float<f128>
Smallest positive normal value.
Sourcepub const MIN_EXP: i32 = -16_381i32
pub const MIN_EXP: i32 = -16_381i32
One greater than the minimum possible normal power of 2 exponent.
Sourcepub const MIN_10_EXP: i32 = -4_931i32
pub const MIN_10_EXP: i32 = -4_931i32
Minimum x for which 10x is normal.
Sourcepub const MAX_10_EXP: i32 = 4_932i32
pub const MAX_10_EXP: i32 = 4_932i32
Maximum x for which 10x is normal.
Sourcepub const PI: Float<f128>
pub const PI: Float<f128>
$ π = \frac{1}{2} τ = 180º $
(A000796)
≈ 3.14159265…
The ratio of the circumference to the diameter, a half-turn.
Sourcepub const FRAC_1_SQRT_PI: Float<f128>
pub const FRAC_1_SQRT_PI: Float<f128>
$ 1/\sqrt{π} = 1/\sqrt{τ/2} $
(A087197)
≈ 0.56418958…
Sourcepub const FRAC_1_SQRT_2PI: Float<f128>
pub const FRAC_1_SQRT_2PI: Float<f128>
$ 1/\sqrt{2π} = 1/\sqrt{τ} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_SQRT_PI: Float<f128>
pub const FRAC_2_SQRT_PI: Float<f128>
$ 2/\sqrt{π} $
(A190732)
≈ 1.12837916…
Sourcepub const TAU: Float<f128>
pub const TAU: Float<f128>
$ τ = 2π = 360º $
(A019692)
≈ 6.28318530…
The ratio of the circumference to the radius, a full-turn.
Sourcepub const FRAC_TAU_2: Float<f128> = Self::PI
pub const FRAC_TAU_2: Float<f128> = Self::PI
$ τ/2 = π = 180º $
(A000796)
≈ 3.14159265…
Sourcepub const FRAC_TAU_3: Float<f128>
pub const FRAC_TAU_3: Float<f128>
$ τ/3 = 2π/3 = 120º $
(A019693)
≈ 2.09439510…
Sourcepub const FRAC_TAU_4: Float<f128> = Self::FRAC_PI_2
pub const FRAC_TAU_4: Float<f128> = Self::FRAC_PI_2
$ τ/4 = π/2 = 90º $
(A019693)
≈ 1.57079632…
Sourcepub const FRAC_TAU_5: Float<f128>
pub const FRAC_TAU_5: Float<f128>
$ τ/5 = 2π/5 = 72º $
(A019694)
≈ 1.25663706…
Sourcepub const FRAC_TAU_6: Float<f128> = Self::FRAC_PI_3
pub const FRAC_TAU_6: Float<f128> = Self::FRAC_PI_3
$ τ/6 = π/3 = 60º $
(A019670)
≈ 1.04719755…
Sourcepub const FRAC_TAU_8: Float<f128> = Self::FRAC_PI_4
pub const FRAC_TAU_8: Float<f128> = Self::FRAC_PI_4
$ τ/8 = π/4 = 45º $
(A003881)
≈ 0.78539816…
Sourcepub const FRAC_TAU_9: Float<f128>
pub const FRAC_TAU_9: Float<f128>
$ τ/9 = 2π/9 = 40º $
(A019696)
≈ 0.69813170…
Sourcepub const FRAC_TAU_12: Float<f128> = Self::FRAC_PI_6
pub const FRAC_TAU_12: Float<f128> = Self::FRAC_PI_6
$ τ/12 = π/6 = 30º $
(A019673)
≈ 0.52359877…
Sourcepub const FRAC_TAU_16: Float<f128> = Self::FRAC_PI_8
pub const FRAC_TAU_16: Float<f128> = Self::FRAC_PI_8
$ τ/16 = π/8 = 22.5º $
(A019675)
≈ 0.39269908…
Sourcepub const FRAC_TAU_24: Float<f128>
pub const FRAC_TAU_24: Float<f128>
$ τ/24 = π/12 = 15º $
(A019679)
≈ 0.26179938…
Sourcepub const FRAC_TAU_72: Float<f128>
pub const FRAC_TAU_72: Float<f128>
$ τ/72 = π/36 = 5º $
≈ 0.08726646…
Sourcepub const FRAC_360_TAU: Float<f128>
pub const FRAC_360_TAU: Float<f128>
$ 360/τ = 180/π $
(A072097)
≈ 57.2957795…
Sourcepub const FRAC_1_TAU: Float<f128>
pub const FRAC_1_TAU: Float<f128>
$ 1/τ = 1/2π $
(A086201)
≈ 0.15915494…
Sourcepub const FRAC_1_SQRT_TAU: Float<f128>
pub const FRAC_1_SQRT_TAU: Float<f128>
$ 1/\sqrt{τ} = 1/\sqrt{2π} $
(A231863)
≈ 0.39894228…
Sourcepub const FRAC_2_TAU: Float<f128> = Self::FRAC_1_PI
pub const FRAC_2_TAU: Float<f128> = Self::FRAC_1_PI
$ 2/τ = 1/π $
(A049541)
≈ 0.31830988…
Sourcepub const FRAC_2_SQRT_TAU: Float<f128>
pub const FRAC_2_SQRT_TAU: Float<f128>
$ 2/\sqrt{τ} = \sqrt{2/π} $
(A076668)
≈ 0.79788456…
Sourcepub const ARC_DEGREE: Float<f128>
pub const ARC_DEGREE: Float<f128>
Sourcepub const ARC_MINUTE: Float<f128>
pub const ARC_MINUTE: Float<f128>
$ τ/(360*60) = 1’ $ arc minute
(wikipedia)
≈ 0.00029088…
Sourcepub const ARC_SECOND: Float<f128>
pub const ARC_SECOND: Float<f128>
$ τ/(360 * 60 * 60) = 1’’ $ arc second
(wikipedia)
≈ 0.00000484…
Sourcepub const PHI: Float<f128>
pub const PHI: Float<f128>
$ φ = (1+\sqrt{5})/2 $
(A001622)
≈ 1.61803398…
The golden ratio.
Continued fraction: $ [1;1,1,1,…] $
Sourcepub const NEG_FRAC_1_PHI: Float<f128>
pub const NEG_FRAC_1_PHI: Float<f128>
$ -1/φ = 1-φ $
≈ -0.61803398…
The negative reciprocal of φ and its conjugate in $ x^2-x-1 $.
Sourcepub const FRAC_1_SQRT_PHI: Float<f128>
pub const FRAC_1_SQRT_PHI: Float<f128>
$ 1/\sqrt{φ} = \sqrt{φ/φ^2} = \sqrt{φ^2-2} $
(A197762)
≈ 0.78615137…
Sourcepub const TRIBONACCI: Float<f128>
pub const TRIBONACCI: Float<f128>
(A058265)
≈ 1.83928675…
The tribonacci constant.
Sourcepub const FRAC_1_SQRT_2: Float<f128>
pub const FRAC_1_SQRT_2: Float<f128>
Sourcepub const FRAC_1_SQRT_3: Float<f128>
pub const FRAC_1_SQRT_3: Float<f128>
$ 1/\sqrt{3} = \sqrt{1/3} $
(A020760,
≈ 0.57735026…
Sourcepub const FRAC_1_CBRT_3: Float<f128>
pub const FRAC_1_CBRT_3: Float<f128>
$ 1/\sqrt[\small 3]{3} = (\normalsize\frac{1}{3})^{\small\frac{1}{3}} $
(A072365)
≈ 0.69336127…
Sourcepub const E: Float<f128>
pub const E: Float<f128>
$ e $
(A001113)
≈ 2.71828182…
The Euler number or Napier’s constant.
Continuous fraction: $ [2;1,2,1,1,4,1,1,6,1,…,1,2n,1,…] $
Source§impl Float<f32>
§This implementation block leverages the libm
feature.
impl Float<f32>
§This implementation block leverages the libm
feature.
Sourcepub fn floor(self) -> Float<f32>
pub fn floor(self) -> Float<f32>
The largest integer less than or equal to x
.
$$ \lfloor x \rfloor = \max { n \in \mathbb{Z} ,|, n \leq x } $$
Sourcepub fn ceil(self) -> Float<f32>
pub fn ceil(self) -> Float<f32>
The smallest integer greater than or equal to x
.
$$ \lceil x \rceil = \min { n \in \mathbb{Z} ,|, n \geq x } $$
Sourcepub fn round_ties_away(self) -> Float<f32>
pub fn round_ties_away(self) -> Float<f32>
The nearest integer to itself, rounding ties away from 0.0
.
Sourcepub fn copysign(self, sign: f32) -> Float<f32>
pub fn copysign(self, sign: f32) -> Float<f32>
A number composed of its magnitude and the sign
of other.
Sourcepub fn mul_add(self, mul: f32, add: f32) -> Float<f32>
pub fn mul_add(self, mul: f32, add: f32) -> Float<f32>
Fused multiply-add. Computes (self * mul) + add with only one rounding error.
Sourcepub fn gamma(self) -> Float<f32>
pub fn gamma(self) -> Float<f32>
The gamma function. Generalizes the factorial function to complex numbers.
Source§impl Float<f64>
§This implementation block leverages the libm
feature.
impl Float<f64>
§This implementation block leverages the libm
feature.
Sourcepub fn floor(self) -> Float<f64>
pub fn floor(self) -> Float<f64>
The largest integer less than or equal to x
.
$$ \lfloor x \rfloor = \max { n \in \mathbb{Z} ,|, n \leq x } $$
Sourcepub fn ceil(self) -> Float<f64>
pub fn ceil(self) -> Float<f64>
The smallest integer greater than or equal to x
.
$$ \lceil x \rceil = \min { n \in \mathbb{Z} ,|, n \geq x } $$
Sourcepub fn round_ties_away(self) -> Float<f64>
pub fn round_ties_away(self) -> Float<f64>
The nearest integer to itself, rounding ties away from 0.0
.
Sourcepub fn copysign(self, sign: f64) -> Float<f64>
pub fn copysign(self, sign: f64) -> Float<f64>
A number composed of its magnitude and the sign
of other.
Sourcepub fn mul_add(self, mul: f64, add: f64) -> Float<f64>
pub fn mul_add(self, mul: f64, add: f64) -> Float<f64>
Fused multiply-add. Computes (self * mul) + add with only one rounding error.
Sourcepub fn gamma(self) -> Float<f64>
pub fn gamma(self) -> Float<f64>
The gamma function. Generalizes the factorial function to complex numbers.
Source§impl Float<f32>
Available on crate feature _float_f32
only.
impl Float<f32>
_float_f32
only.§Implementations using the libm
feature.
Sourcepub fn split(self) -> (Float<f32>, Float<f32>) ⓘ
pub fn split(self) -> (Float<f32>, Float<f32>) ⓘ
The integral and fractional parts.
§Formulation
$$ \text{split}(x) = (\text{trunc}(x), \text{fract}(x)) $$
Sourcepub fn round_ties_even(self) -> Float<f32>
pub fn round_ties_even(self) -> Float<f32>
Returns the nearest integer to x
, rounding ties to the nearest even integer.
Sourcepub fn clamp(self, min: f32, max: f32) -> Float<f32>
pub fn clamp(self, min: f32, max: f32) -> Float<f32>
Returns itself clamped between min
and max
, ignoring NaN
.
Sourcepub fn log(self, base: f32) -> Float<f32>
pub fn log(self, base: f32) -> Float<f32>
The logarithm of the number with respect to an arbitrary base.
Source§impl Float<f64>
Available on crate feature _float_f64
only.
impl Float<f64>
_float_f64
only.§Implementations using the libm
feature.
Sourcepub fn split(self) -> (Float<f64>, Float<f64>) ⓘ
pub fn split(self) -> (Float<f64>, Float<f64>) ⓘ
The integral and fractional parts.
§Formulation
$$ \text{split}(x) = (\text{trunc}(x), \text{fract}(x)) $$
Sourcepub fn round_ties_even(self) -> Float<f64>
pub fn round_ties_even(self) -> Float<f64>
Returns the nearest integer to x
, rounding ties to the nearest even integer.
Sourcepub fn clamp(self, min: f64, max: f64) -> Float<f64>
pub fn clamp(self, min: f64, max: f64) -> Float<f64>
Returns itself clamped between min
and max
, ignoring NaN
.
Sourcepub fn log(self, base: f64) -> Float<f64>
pub fn log(self, base: f64) -> Float<f64>
The logarithm of the number with respect to an arbitrary base.
Source§impl Float<f32>
Available on crate feature _float_f32
only.
impl Float<f32>
_float_f32
only.§Common implementations with or without std
or libm
.
Sourcepub const fn const_floor(self) -> Float<f32>
pub const fn const_floor(self) -> Float<f32>
The largest integer less than or equal to itself.
§Formulation
$$ \large \lfloor x \rfloor = \max { n \in \mathbb{Z} ,|, n \leq x } $$
Sourcepub const fn const_ceil(self) -> Float<f32>
pub const fn const_ceil(self) -> Float<f32>
The smallest integer greater than or equal to itself.
§Formulation
$$ $$ \lceil x \rceil = \min { n \in \mathbb{Z} ,|, n \geq x } $$
Sourcepub const fn const_round(self) -> Float<f32>
pub const fn const_round(self) -> Float<f32>
The nearest integer to itself, default rounding
This is the default [round_ties_away
] implementation.
Sourcepub const fn const_round_ties_away(self) -> Float<f32>
pub const fn const_round_ties_away(self) -> Float<f32>
The nearest integer to itself, rounding ties away from 0.0
.
This is the default [round
] implementation.
§Formulation
$$ \text{round\_ties\_away}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \text{ or } (x - \lfloor x \rfloor = 0.5 \text{ and } x > 0) \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \text{ or } (x - \lfloor x \rfloor = 0.5 \text{ and } x < 0) \end{cases} $$
Sourcepub const fn const_round_ties_even(self) -> Float<f32>
pub const fn const_round_ties_even(self) -> Float<f32>
Returns the nearest integer to x
, rounding ties to the nearest even integer.
§Formulation
$$ \text{round\_ties\_even}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is even} \cr \lceil x \rceil, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is odd} \end{cases} $$
Sourcepub const fn const_trunc(self) -> Float<f32>
pub const fn const_trunc(self) -> Float<f32>
The integral part. This means that non-integer numbers are always truncated towards zero.
§Formulation
$$ \text{trunc}(x) = \begin{cases} \lfloor x \rfloor, & \text{if } x \geq 0 \ \lceil x \rceil, & \text{if } x < 0 \end{cases} $$
This implementation uses bitwise manipulation to remove the fractional part of the floating-point number. The exponent is extracted, and a mask is created to remove the fractional part. The new bits are then used to create the truncated floating-point number.
Sourcepub fn const_round_ties_odd(self) -> Float<f32>
pub fn const_round_ties_odd(self) -> Float<f32>
Returns the nearest integer, rounding ties to the nearest odd integer.
§Formulation
$$ \text{round\_ties\_odd}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is odd} \cr \lceil x \rceil, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is even} \end{cases} $$
Sourcepub fn round_ties_odd(self) -> Float<f32>
pub fn round_ties_odd(self) -> Float<f32>
Returns the nearest integer, rounding ties to the nearest odd integer.
§Formulation
$$ \text{round\_ties\_odd}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is odd} \cr \lceil x \rceil, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is even} \end{cases} $$
Sourcepub const fn const_fract(self) -> Float<f32>
pub const fn const_fract(self) -> Float<f32>
Sourcepub const fn const_split(self) -> (Float<f32>, Float<f32>) ⓘ
pub const fn const_split(self) -> (Float<f32>, Float<f32>) ⓘ
The integral and fractional parts.
§Formulation
$$ \text{split}(x) = (\text{trunc}(x), \text{fract}(x)) $$
Sourcepub const fn const_signum(self) -> Float<f32>
pub const fn const_signum(self) -> Float<f32>
A number that represents its sign, propagating NaN
.
Sourcepub const fn const_copysign(self, sign: f32) -> Float<f32>
pub const fn const_copysign(self, sign: f32) -> Float<f32>
A number composed of the magnitude of itself and the sign
of other.
Sourcepub const fn sign_nonzero(self) -> Sign
pub const fn sign_nonzero(self) -> Sign
Sourcepub const fn is_sign_positive(self) -> bool
pub const fn is_sign_positive(self) -> bool
Returns true
if self
has a positive sign.
Sourcepub const fn is_sign_negative(self) -> bool
pub const fn is_sign_negative(self) -> bool
Returns true
if self
has a negative sign.
Sourcepub const fn is_sign_positive_nonzero(self) -> bool
pub const fn is_sign_positive_nonzero(self) -> bool
Returns true
if self
has a positive sign and is not zero.
Sourcepub const fn is_sign_negative_nonzero(self) -> bool
pub const fn is_sign_negative_nonzero(self) -> bool
Returns true
if self
has a negative sign and is not zero.
Sourcepub const fn mul_add_fallback(self, mul: f32, add: f32) -> Float<f32>
pub const fn mul_add_fallback(self, mul: f32, add: f32) -> Float<f32>
Computes (x * mul + add)
normally.
Sourcepub fn div_euclid(self, other: f32) -> Float<f32>
pub fn div_euclid(self, other: f32) -> Float<f32>
The euclidean division.
Sourcepub const fn rem_euclid(self, other: f32) -> Float<f32>
pub const fn rem_euclid(self, other: f32) -> Float<f32>
The least non-negative remainder of self
% other
.
Sourcepub const fn scale(self, min: f32, max: f32, u: f32, v: f32) -> Float<f32>
pub const fn scale(self, min: f32, max: f32, u: f32, v: f32) -> Float<f32>
Returns self
between [min..=max]
scaled to a new range [u..=v]
.
Values of self
outside of [min..=max]
are not clamped
and will result in extrapolation.
§Formulation
$$ \large \text{scale}(x, min, max, u, v) = (v - u) \frac{x - min}{max - min} + u $$
§Examples
assert_eq![Float(45_f32).scale(0., 360., 0., 1.), 0.125];
assert_eq![Float(45_f32).scale(0., 360., -1., 1.), -0.75];
assert_eq![Float(0.125_f32).scale(0., 1., 0., 360.), 45.];
assert_eq![Float(-0.75_f32).scale(-1., 1., 0., 360.), 45.];
Sourcepub const fn lerp(self, u: f32, v: f32) -> Float<f32>
pub const fn lerp(self, u: f32, v: f32) -> Float<f32>
Calculates a linearly interpolated value between u..=v
based on self
as a percentage between [0..=1]
.
Values of self
outside [0..=1]
are not clamped
and will result in extrapolation.
§Formulation
$$ \large \text{lerp}(x, u, v) = (1 - x) \cdot u + x \cdot v $$
§Example
assert_eq![Float(0.5_f32).lerp(40., 80.), 60.];
Sourcepub const fn fisr(self) -> Float<f32>
pub const fn fisr(self) -> Float<f32>
$ 1 / \sqrt{x} $ the fast inverse square root algorithm.
Sourcepub const fn sqrt_nr(self) -> Float<f32>
pub const fn sqrt_nr(self) -> Float<f32>
$ \sqrt{x} $ The square root calculated using the Newton-Raphson method.
Sourcepub const fn sqrt_fisr(self) -> Float<f32>
pub const fn sqrt_fisr(self) -> Float<f32>
$ \sqrt{x} $ the square root calculated using the fast inverse square root algorithm.
Sourcepub const fn hypot_fisr(self, y: f32) -> Float<f32>
pub const fn hypot_fisr(self, y: f32) -> Float<f32>
The hypothenuse (the euclidean distance) using the fast inverse square root algorithm.
§Formulation
$$ \text{hypot}(x, y) = \sqrt{x^2 + y^2} $$
Sourcepub const fn hypot_nr(self, y: f32) -> Float<f32>
pub const fn hypot_nr(self, y: f32) -> Float<f32>
The hypothenuse (the euclidean distance) using the Newton-Raphson method.
§Formulation
$$ \text{hypot}(x, y) = \sqrt{x^2 + y^2} $$
Sourcepub const fn cbrt_nr(self) -> Float<f32>
pub const fn cbrt_nr(self) -> Float<f32>
$ \sqrt[3]{x} $ The cubic root calculated using the Newton-Raphson method.
Sourcepub const fn factorial(x: u32) -> Float<f32>
pub const fn factorial(x: u32) -> Float<f32>
The factorial of the integer value x
.
The maximum values with a representable result are:
34 for f32
and 170 for f64
.
Note that precision is poor for large values.
Sourcepub const fn neg_abs(self) -> Float<f32>
pub const fn neg_abs(self) -> Float<f32>
The negative absolute value of self
(sets its sign to be negative).
Sourcepub const fn const_clamp(self, min: f32, max: f32) -> Float<f32>
pub const fn const_clamp(self, min: f32, max: f32) -> Float<f32>
Returns itself clamped between min
and max
, ignoring NaN
.
§Example
assert_eq![Float(50.0_f32).clamp(40., 80.), 50.];
assert_eq![Float(100.0_f32).clamp(40., 80.), 80.];
assert_eq![Float(10.0_f32).clamp(40., 80.), 40.];
See also: clamp_nan
, clamp_total
.
Sourcepub const fn const_max(self, other: f32) -> Float<f32>
pub const fn const_max(self, other: f32) -> Float<f32>
The maximum between itself and other
, ignoring NaN
.
Sourcepub const fn const_min(self, other: f32) -> Float<f32>
pub const fn const_min(self, other: f32) -> Float<f32>
The minimum between itself and other, ignoring NaN
.
Sourcepub const fn clamp_total(self, min: f32, max: f32) -> Float<f32>
Available on crate feature _cmp_f32
only.
pub const fn clamp_total(self, min: f32, max: f32) -> Float<f32>
_cmp_f32
only.Sourcepub const fn max_total(self, other: f32) -> Float<f32>
Available on crate feature _cmp_f32
only.
pub const fn max_total(self, other: f32) -> Float<f32>
_cmp_f32
only.Returns the maximum between itself and other
, using total order.
See also: max_nan
.
Sourcepub fn min_total(self, other: f32) -> Float<f32>
Available on crate feature _cmp_f32
only.
pub fn min_total(self, other: f32) -> Float<f32>
_cmp_f32
only.Returns the minimum between itself and other
, using total order.
See also: min_nan
.
Sourcepub const fn clamp_nan(self, min: f32, max: f32) -> Float<f32>
pub const fn clamp_nan(self, min: f32, max: f32) -> Float<f32>
Returns itself clamped between min
and max
, propagating NaN
.
§Example
assert_eq![Float(50.0_f32).clamp_nan(40., 80.), 50.];
assert_eq![Float(100.0_f32).clamp_nan(40., 80.), 80.];
assert_eq![Float(10.0_f32).clamp_nan(40., 80.), 40.];
See also: clamp
, clamp_total
.
Sourcepub const fn const_powi(self, p: i32) -> Float<f32>
pub const fn const_powi(self, p: i32) -> Float<f32>
Raises itself to the p
integer power.
Sourcepub const fn eval_poly(self, coefficients: &[f32]) -> Float<f32>
pub const fn eval_poly(self, coefficients: &[f32]) -> Float<f32>
Evaluates a polynomial at the self
point value, using Horner’s method.
Expects a slice of coefficients
$[a_n, a_{n-1}, …, a_1, a_0]$
representing the polynomial $ a_n * x^n + a_{n-1} * x^{(n-1)} + … + a_1 * x + a_0 $.
§Examples
let coefficients = [2.0, -6.0, 2.0, -1.0];
assert_eq![Float(3.0_f32).eval_poly(&coefficients), 5.0];
assert_eq![Float(3.0_f32).eval_poly(&[]), 0.0];
Sourcepub fn derivative<F>(f: F, x: f32, h: f32) -> Float<f32>
pub fn derivative<F>(f: F, x: f32, h: f32) -> Float<f32>
Approximates the derivative of the 1D function f
at x
point using step size h
.
Uses the finite difference method.
§Formulation
$$ f’(x) \approx \frac{f(x + h) - f(x)}{h} $$
See also the autodiff
attr macro, enabled with the nightly_autodiff
feature.
Sourcepub fn integrate<F>(f: F, x: f32, y: f32, n: usize) -> Float<f32>
pub fn integrate<F>(f: F, x: f32, y: f32, n: usize) -> Float<f32>
Approximates the integral of the 1D function f
over the range [x, y]
using n
subdivisions.
Uses the Riemann Sum.
§Formulation
$$ \int_a^b f(x) , dx \approx \sum_{i=0}^{n-1} f(x_i) \cdot \Delta x $$ where $$ \Delta x = \frac{b-a}{n} $$
Sourcepub fn partial_derivative_x<F>(f: F, x: f32, y: f32, h: f32) -> Float<f32>
pub fn partial_derivative_x<F>(f: F, x: f32, y: f32, h: f32) -> Float<f32>
Approximates the partial derivative of the 2D function f
at point (x
, y
)
with step size h
, differentiating over x
.
§Formulation
\frac{\partial f}{\partial x} \approx \frac{f(x + h, y) - f(x, y)}{h} $$
Source§impl Float<f64>
Available on crate feature _float_f64
only.
impl Float<f64>
_float_f64
only.§Common implementations with or without std
or libm
.
Sourcepub const fn const_floor(self) -> Float<f64>
pub const fn const_floor(self) -> Float<f64>
The largest integer less than or equal to itself.
§Formulation
$$ \large \lfloor x \rfloor = \max { n \in \mathbb{Z} ,|, n \leq x } $$
Sourcepub const fn const_ceil(self) -> Float<f64>
pub const fn const_ceil(self) -> Float<f64>
The smallest integer greater than or equal to itself.
§Formulation
$$ $$ \lceil x \rceil = \min { n \in \mathbb{Z} ,|, n \geq x } $$
Sourcepub const fn const_round(self) -> Float<f64>
pub const fn const_round(self) -> Float<f64>
The nearest integer to itself, default rounding
This is the default [round_ties_away
] implementation.
Sourcepub const fn const_round_ties_away(self) -> Float<f64>
pub const fn const_round_ties_away(self) -> Float<f64>
The nearest integer to itself, rounding ties away from 0.0
.
This is the default [round
] implementation.
§Formulation
$$ \text{round\_ties\_away}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \text{ or } (x - \lfloor x \rfloor = 0.5 \text{ and } x > 0) \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \text{ or } (x - \lfloor x \rfloor = 0.5 \text{ and } x < 0) \end{cases} $$
Sourcepub const fn const_round_ties_even(self) -> Float<f64>
pub const fn const_round_ties_even(self) -> Float<f64>
Returns the nearest integer to x
, rounding ties to the nearest even integer.
§Formulation
$$ \text{round\_ties\_even}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is even} \cr \lceil x \rceil, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is odd} \end{cases} $$
Sourcepub const fn const_trunc(self) -> Float<f64>
pub const fn const_trunc(self) -> Float<f64>
The integral part. This means that non-integer numbers are always truncated towards zero.
§Formulation
$$ \text{trunc}(x) = \begin{cases} \lfloor x \rfloor, & \text{if } x \geq 0 \ \lceil x \rceil, & \text{if } x < 0 \end{cases} $$
This implementation uses bitwise manipulation to remove the fractional part of the floating-point number. The exponent is extracted, and a mask is created to remove the fractional part. The new bits are then used to create the truncated floating-point number.
Sourcepub fn const_round_ties_odd(self) -> Float<f64>
pub fn const_round_ties_odd(self) -> Float<f64>
Returns the nearest integer, rounding ties to the nearest odd integer.
§Formulation
$$ \text{round\_ties\_odd}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is odd} \cr \lceil x \rceil, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is even} \end{cases} $$
Sourcepub fn round_ties_odd(self) -> Float<f64>
pub fn round_ties_odd(self) -> Float<f64>
Returns the nearest integer, rounding ties to the nearest odd integer.
§Formulation
$$ \text{round\_ties\_odd}(x) = \begin{cases} \lceil x \rceil, & \text{if } x - \lfloor x \rfloor > 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor < 0.5 \cr \lfloor x \rfloor, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is odd} \cr \lceil x \rceil, & \text{if } x - \lfloor x \rfloor = 0.5 \text{ and } \lfloor x \rfloor \text{ is even} \end{cases} $$
Sourcepub const fn const_fract(self) -> Float<f64>
pub const fn const_fract(self) -> Float<f64>
Sourcepub const fn const_split(self) -> (Float<f64>, Float<f64>) ⓘ
pub const fn const_split(self) -> (Float<f64>, Float<f64>) ⓘ
The integral and fractional parts.
§Formulation
$$ \text{split}(x) = (\text{trunc}(x), \text{fract}(x)) $$
Sourcepub const fn const_signum(self) -> Float<f64>
pub const fn const_signum(self) -> Float<f64>
A number that represents its sign, propagating NaN
.
Sourcepub const fn const_copysign(self, sign: f64) -> Float<f64>
pub const fn const_copysign(self, sign: f64) -> Float<f64>
A number composed of the magnitude of itself and the sign
of other.
Sourcepub const fn sign_nonzero(self) -> Sign
pub const fn sign_nonzero(self) -> Sign
Sourcepub const fn is_sign_positive(self) -> bool
pub const fn is_sign_positive(self) -> bool
Returns true
if self
has a positive sign.
Sourcepub const fn is_sign_negative(self) -> bool
pub const fn is_sign_negative(self) -> bool
Returns true
if self
has a negative sign.
Sourcepub const fn is_sign_positive_nonzero(self) -> bool
pub const fn is_sign_positive_nonzero(self) -> bool
Returns true
if self
has a positive sign and is not zero.
Sourcepub const fn is_sign_negative_nonzero(self) -> bool
pub const fn is_sign_negative_nonzero(self) -> bool
Returns true
if self
has a negative sign and is not zero.
Sourcepub const fn mul_add_fallback(self, mul: f64, add: f64) -> Float<f64>
pub const fn mul_add_fallback(self, mul: f64, add: f64) -> Float<f64>
Computes (x * mul + add)
normally.
Sourcepub fn div_euclid(self, other: f64) -> Float<f64>
pub fn div_euclid(self, other: f64) -> Float<f64>
The euclidean division.
Sourcepub const fn rem_euclid(self, other: f64) -> Float<f64>
pub const fn rem_euclid(self, other: f64) -> Float<f64>
The least non-negative remainder of self
% other
.
Sourcepub const fn scale(self, min: f64, max: f64, u: f64, v: f64) -> Float<f64>
pub const fn scale(self, min: f64, max: f64, u: f64, v: f64) -> Float<f64>
Returns self
between [min..=max]
scaled to a new range [u..=v]
.
Values of self
outside of [min..=max]
are not clamped
and will result in extrapolation.
§Formulation
$$ \large \text{scale}(x, min, max, u, v) = (v - u) \frac{x - min}{max - min} + u $$
§Examples
assert_eq![Float(45_f64).scale(0., 360., 0., 1.), 0.125];
assert_eq![Float(45_f64).scale(0., 360., -1., 1.), -0.75];
assert_eq![Float(0.125_f64).scale(0., 1., 0., 360.), 45.];
assert_eq![Float(-0.75_f64).scale(-1., 1., 0., 360.), 45.];
Sourcepub const fn lerp(self, u: f64, v: f64) -> Float<f64>
pub const fn lerp(self, u: f64, v: f64) -> Float<f64>
Calculates a linearly interpolated value between u..=v
based on self
as a percentage between [0..=1]
.
Values of self
outside [0..=1]
are not clamped
and will result in extrapolation.
§Formulation
$$ \large \text{lerp}(x, u, v) = (1 - x) \cdot u + x \cdot v $$
§Example
assert_eq![Float(0.5_f64).lerp(40., 80.), 60.];
Sourcepub const fn fisr(self) -> Float<f64>
pub const fn fisr(self) -> Float<f64>
$ 1 / \sqrt{x} $ the fast inverse square root algorithm.
Sourcepub const fn sqrt_nr(self) -> Float<f64>
pub const fn sqrt_nr(self) -> Float<f64>
$ \sqrt{x} $ The square root calculated using the Newton-Raphson method.
Sourcepub const fn sqrt_fisr(self) -> Float<f64>
pub const fn sqrt_fisr(self) -> Float<f64>
$ \sqrt{x} $ the square root calculated using the fast inverse square root algorithm.
Sourcepub const fn hypot_fisr(self, y: f64) -> Float<f64>
pub const fn hypot_fisr(self, y: f64) -> Float<f64>
The hypothenuse (the euclidean distance) using the fast inverse square root algorithm.
§Formulation
$$ \text{hypot}(x, y) = \sqrt{x^2 + y^2} $$
Sourcepub const fn hypot_nr(self, y: f64) -> Float<f64>
pub const fn hypot_nr(self, y: f64) -> Float<f64>
The hypothenuse (the euclidean distance) using the Newton-Raphson method.
§Formulation
$$ \text{hypot}(x, y) = \sqrt{x^2 + y^2} $$
Sourcepub const fn cbrt_nr(self) -> Float<f64>
pub const fn cbrt_nr(self) -> Float<f64>
$ \sqrt[3]{x} $ The cubic root calculated using the Newton-Raphson method.
Sourcepub const fn factorial(x: u32) -> Float<f64>
pub const fn factorial(x: u32) -> Float<f64>
The factorial of the integer value x
.
The maximum values with a representable result are:
34 for f32
and 170 for f64
.
Note that precision is poor for large values.
Sourcepub const fn neg_abs(self) -> Float<f64>
pub const fn neg_abs(self) -> Float<f64>
The negative absolute value of self
(sets its sign to be negative).
Sourcepub const fn const_clamp(self, min: f64, max: f64) -> Float<f64>
pub const fn const_clamp(self, min: f64, max: f64) -> Float<f64>
Returns itself clamped between min
and max
, ignoring NaN
.
§Example
assert_eq![Float(50.0_f64).clamp(40., 80.), 50.];
assert_eq![Float(100.0_f64).clamp(40., 80.), 80.];
assert_eq![Float(10.0_f64).clamp(40., 80.), 40.];
See also: clamp_nan
, clamp_total
.
Sourcepub const fn const_max(self, other: f64) -> Float<f64>
pub const fn const_max(self, other: f64) -> Float<f64>
The maximum between itself and other
, ignoring NaN
.
Sourcepub const fn const_min(self, other: f64) -> Float<f64>
pub const fn const_min(self, other: f64) -> Float<f64>
The minimum between itself and other, ignoring NaN
.
Sourcepub const fn clamp_total(self, min: f64, max: f64) -> Float<f64>
Available on crate feature _cmp_f64
only.
pub const fn clamp_total(self, min: f64, max: f64) -> Float<f64>
_cmp_f64
only.Sourcepub const fn max_total(self, other: f64) -> Float<f64>
Available on crate feature _cmp_f64
only.
pub const fn max_total(self, other: f64) -> Float<f64>
_cmp_f64
only.Returns the maximum between itself and other
, using total order.
See also: max_nan
.
Sourcepub fn min_total(self, other: f64) -> Float<f64>
Available on crate feature _cmp_f64
only.
pub fn min_total(self, other: f64) -> Float<f64>
_cmp_f64
only.Returns the minimum between itself and other
, using total order.
See also: min_nan
.
Sourcepub const fn clamp_nan(self, min: f64, max: f64) -> Float<f64>
pub const fn clamp_nan(self, min: f64, max: f64) -> Float<f64>
Returns itself clamped between min
and max
, propagating NaN
.
§Example
assert_eq![Float(50.0_f64).clamp_nan(40., 80.), 50.];
assert_eq![Float(100.0_f64).clamp_nan(40., 80.), 80.];
assert_eq![Float(10.0_f64).clamp_nan(40., 80.), 40.];
See also: clamp
, clamp_total
.
Sourcepub const fn const_powi(self, p: i32) -> Float<f64>
pub const fn const_powi(self, p: i32) -> Float<f64>
Raises itself to the p
integer power.
Sourcepub const fn eval_poly(self, coefficients: &[f64]) -> Float<f64>
pub const fn eval_poly(self, coefficients: &[f64]) -> Float<f64>
Evaluates a polynomial at the self
point value, using Horner’s method.
Expects a slice of coefficients
$[a_n, a_{n-1}, …, a_1, a_0]$
representing the polynomial $ a_n * x^n + a_{n-1} * x^{(n-1)} + … + a_1 * x + a_0 $.
§Examples
let coefficients = [2.0, -6.0, 2.0, -1.0];
assert_eq![Float(3.0_f64).eval_poly(&coefficients), 5.0];
assert_eq![Float(3.0_f64).eval_poly(&[]), 0.0];
Sourcepub fn derivative<F>(f: F, x: f64, h: f64) -> Float<f64>
pub fn derivative<F>(f: F, x: f64, h: f64) -> Float<f64>
Approximates the derivative of the 1D function f
at x
point using step size h
.
Uses the finite difference method.
§Formulation
$$ f’(x) \approx \frac{f(x + h) - f(x)}{h} $$
See also the autodiff
attr macro, enabled with the nightly_autodiff
feature.
Sourcepub fn integrate<F>(f: F, x: f64, y: f64, n: usize) -> Float<f64>
pub fn integrate<F>(f: F, x: f64, y: f64, n: usize) -> Float<f64>
Approximates the integral of the 1D function f
over the range [x, y]
using n
subdivisions.
Uses the Riemann Sum.
§Formulation
$$ \int_a^b f(x) , dx \approx \sum_{i=0}^{n-1} f(x_i) \cdot \Delta x $$ where $$ \Delta x = \frac{b-a}{n} $$
Sourcepub fn partial_derivative_x<F>(f: F, x: f64, y: f64, h: f64) -> Float<f64>
pub fn partial_derivative_x<F>(f: F, x: f64, y: f64, h: f64) -> Float<f64>
Approximates the partial derivative of the 2D function f
at point (x
, y
)
with step size h
, differentiating over x
.
§Formulation
\frac{\partial f}{\partial x} \approx \frac{f(x + h, y) - f(x, y)}{h} $$
Source§impl Float<f32>
Available on crate feature _float_f32
only.
impl Float<f32>
_float_f32
only.§Common methods with or without std
or libm
.
Implemented using Taylor series.
Sourcepub const fn powf_series(self, y: f32, ln_x_terms: u32) -> Float<f32>
pub const fn powf_series(self, y: f32, ln_x_terms: u32) -> Float<f32>
Raises itself to the y
floating point power using the Taylor series via the
exp
and ln
functions.
§Formulation
$$ \large x^y = e^{y \cdot \ln(x)} $$
See also ln_series_terms
.
The terms for the exponential function are calculated using
exp_series_terms
using $y\cdot\ln(x)$.
Sourcepub const fn exp_series(self, terms: u32) -> Float<f32>
pub const fn exp_series(self, terms: u32) -> Float<f32>
Computes the exponential function $e^x$ using Taylor series expansion.
§Formulation
$$ e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots $$ For values $ x < 0 $ it uses the identity: $$ e^x = \frac{1}{e^-x} $$
See also exp_series_terms
.
Sourcepub const fn exp_series_terms(self) -> u32 ⓘ
pub const fn exp_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for exp_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 5
± 0.100 → 6 10
± 1.000 → 11 18
± 10.000 → 32 46
± 20.000 → 49 68
± 50.000 → 92 119
± 88.722 → 143 177 (max for f32 == f32::MAX.ln())
± 150.000 → --- 261
± 300.000 → --- 453
± 500.000 → --- 692
± 709.782 → --- 938 (max for f64 == f64:MAX.ln())
Sourcepub const fn exp_m1_series(self, terms: u32) -> Float<f32>
pub const fn exp_m1_series(self, terms: u32) -> Float<f32>
Calculates $ e^x - 1 $ using the Taylor series expansion.
§Formulation
$$
e^x -1 = x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots $$
For values $ x < 0 $ it uses the identity: $$ e^x -1 = -\frac{1}{e^{-x}+1} $$
For values $ x > 0.001 $ it uses exp_series
.
See also exp_series_terms
.
Sourcepub const fn exp2_series(self, terms: u32) -> Float<f32>
pub const fn exp2_series(self, terms: u32) -> Float<f32>
Calculates $ 2^x $ using the Taylor series expansion.
§Formulation
The series based on the formula $ 2^x = e^{x \ln(2)} $ is: $$ 2^x = 1 + x \ln(2) + \frac{(x \ln(2))^2}{2!} + \frac{(x \ln(2))^3}{3!} + \frac{(x \ln(2))^4}{4!} + \cdots $$
The maximum values with a representable result are:
127 for f32
and 1023 for f64
.
Sourcepub const fn exp2_series_terms(self) -> u32 ⓘ
pub const fn exp2_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for exp2_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.3 → 8 13
± 3.0 → 15 25
± 7.0 → 22 34
± 15.0 → 34 49
± 31.0 → 52 71
± 63.0 → 84 110
± 127.999 → 144 178 (max for f32)
± 255.0 → --- 298
± 511.0 → --- 520
± 1023.999 → --- 939 (max for f64)
Sourcepub const fn ln_series(self, terms: u32) -> Float<f32>
pub const fn ln_series(self, terms: u32) -> Float<f32>
Computes the natural logarithm of self
using a Taylor-Mercator series expansion.
This method is more efficient for values of self
near 1. Values too
small or too big could be impractical to calculate with precision.
§Formulation
$$ \ln(x) = 2 \left( \frac{x-1}{x+1} + \frac{1}{3} \left( \frac{x-1}{x+1} \right)^3 + \frac{1}{5} \left( \frac{x-1}{x+1} \right)^5 + \cdots \right) $$
See also ln_series_terms
.
Sourcepub const fn ln_1p_series(self, terms: u32) -> Float<f32>
pub const fn ln_1p_series(self, terms: u32) -> Float<f32>
Computes the natural logarithm of 1 + self
using a Taylor-Mercator series expansion.
This method is more efficient for values of self
near 0.
Values too small or too big could be impractical to calculate with precision.
Returns ln(1+self)
more accurately
than if the operations were performed separately.
See also ln_series_terms
.
Sourcepub const fn log_series(self, base: f32, terms: u32) -> Float<f32>
pub const fn log_series(self, base: f32, terms: u32) -> Float<f32>
Computes the logarithm to the given base
using the change of base formula.
§Formulation
$$ \log_{\text{base}}(x) = \frac{\ln(x)}{\ln(\text{base})} $$
See also ln_series_terms
.
Sourcepub const fn log2_series(self, terms: u32) -> Float<f32>
pub const fn log2_series(self, terms: u32) -> Float<f32>
Computes the base-2 logarithm using the change of base formula.
§Formulation
$$ \log_{2}(x) = \frac{\ln(x)}{\ln(2)} $$
See also ln_series_terms
.
Sourcepub const fn log10_series(self, terms: u32) -> Float<f32>
pub const fn log10_series(self, terms: u32) -> Float<f32>
Computes the base-10 logarithm using the change of base formula.
§Formulation
$$ \log_{10}(x) = \frac{\ln(x)}{\ln(10)} $$
See also ln_series_terms
.
Sourcepub const fn ln_series_terms(self) -> u32 ⓘ
pub const fn ln_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for exp2_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
--------------------------
± 0.00001 → 81181 536609
± 0.0001 → 12578 59174
± 0.001 → 1923 6639
± 0.01. → 245 720
± 0.1 → 32 80
± 0.5 → 8 17
± 1. → 1 1
± 2. → 8 17
± 10. → 32 80
± 100. → 245 720
± 1000. → 1923 6639
± 10000. → 12578 59174
± 100000. → 81181 536609
/// ```
Sourcepub const fn sin_series(self, terms: u32) -> Float<f32>
pub const fn sin_series(self, terms: u32) -> Float<f32>
The sine calculated using Taylor series expansion.
§Formulation
$$ \sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots $$
This Taylor series converges relatively quickly and uniformly
over the entire domain.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 4 6
± 0.300 → 5 7
± 0.500 → 5 8
± 0.700 → 6 9
± 0.900 → 6 10
± 0.999 → 6 10
Sourcepub const fn cos_series(self, terms: u32) -> Float<f32>
pub const fn cos_series(self, terms: u32) -> Float<f32>
Computes the cosine using taylor series expansion.
§Formulation
$$ \cos(x) = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots $$
This Taylor series converges relatively quickly and uniformly
over the entire domain.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 4 6
± 0.300 → 5 8
± 0.500 → 6 9
± 0.700 → 6 10
± 0.900 → 7 10
± 0.999 → 7 11
Sourcepub const fn sin_cos_series(self, terms: u32) -> (Float<f32>, Float<f32>) ⓘ
pub const fn sin_cos_series(self, terms: u32) -> (Float<f32>, Float<f32>) ⓘ
Computes the sine and the cosine using Taylor series expansion.
Sourcepub const fn tan_series(self, terms: u32) -> Float<f32>
pub const fn tan_series(self, terms: u32) -> Float<f32>
Computes the tangent using Taylor series expansion of sine and cosine.
§Formulation
$$ \tan(x) = \frac{\sin(x)}{\cos(x)} $$
The tangent function has singularities and is not defined for
cos(x) = 0
. This function clamps self
within an appropriate range
to avoid such issues.
The Taylor series for sine and cosine converge relatively quickly
and uniformly over the entire domain.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 4 6
± 0.300 → 5 8
± 0.500 → 6 9
± 0.700 → 6 10
± 0.900 → 7 10
± 0.999 → 7 11
Sourcepub const fn asin_series(self, terms: u32) -> Float<f32>
pub const fn asin_series(self, terms: u32) -> Float<f32>
Computes the arcsine using Taylor series expansion.
§Formulation
$$ \arcsin(x) = x + \left( \frac{1}{2} \right) \frac{x^3}{3} + \left( \frac{1}{2} \cdot \frac{3}{4} \right) \frac{x^5}{5} + \left( \frac{1}{2} \cdot \frac{3}{4} \cdot \frac{5}{6} \right) \frac{x^7}{7} + \cdots $$
asin is undefined for $ |x| > 1 $ and in that case returns NaN
.
The series converges more slowly near the edges of the domain
(i.e., as self
approaches -1 or 1). For more accurate results,
especially near these boundary values, a higher number of terms
may be necessary.
See also asin_series_terms
.
Sourcepub const fn asin_series_terms(self) -> u32 ⓘ
pub const fn asin_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for asin_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 5 9
± 0.300 → 7 15
± 0.500 → 10 24
± 0.700 → 18 44
± 0.900 → 47 134
± 0.990 → 333 1235
± 0.999 → 1989 10768
Sourcepub const fn acos_series(self, terms: u32) -> Float<f32>
pub const fn acos_series(self, terms: u32) -> Float<f32>
Computes the arccosine using the Taylor expansion of arcsine.
§Formulation
$$ \arccos(x)=2π-arcsin(x) $$
See the asin_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn acos_series_terms(self) -> u32 ⓘ
pub const fn acos_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for acos_series
to reach a stable result based on the input value.
The table is the same as asin_series_terms
.
Sourcepub const fn atan_series(self, terms: u32) -> Float<f32>
pub const fn atan_series(self, terms: u32) -> Float<f32>
Computes the arctangent using Taylor series expansion.
§Formulation
$$ \arctan(x) = x - \frac{x^3}{3} + \frac{x^5}{5} - \frac{x^7}{7} + \cdots $$ For values $ |x| > 1 $ it uses the identity: $$ \arctan(x) = \frac{\pi}{2} - \arctan(\frac{1}{x}) $$
The series converges more slowly near the edges of the domain
(i.e., as self
approaches -1 or 1). For more accurate results,
especially near these boundary values, a higher number of terms
may be necessary.
See also atan_series_terms
.
Sourcepub const fn atan_series_terms(self) -> u32 ⓘ
pub const fn atan_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for atan_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 5 9
± 0.300 → 7 15
± 0.500 → 12 26
± 0.700 → 20 47
± 0.900 → 61 152
± 0.990 → 518 1466
± 0.999 → 4151 13604
Sourcepub const fn atan2_series(self, other: f32, terms: u32) -> Float<f32>
pub const fn atan2_series(self, other: f32, terms: u32) -> Float<f32>
Computes the four quadrant arctangent of self
and other
using Taylor series expansion.
See also atan_series_terms
.
Sourcepub const fn sinh_series(self, terms: u32) -> Float<f32>
pub const fn sinh_series(self, terms: u32) -> Float<f32>
The hyperbolic sine calculated using Taylor series expansion via the exponent formula.
§Formulation
$$ \sinh(x) = \frac{e^x - e^{-x}}{2} $$
See the exp_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn cosh_series(self, terms: u32) -> Float<f32>
pub const fn cosh_series(self, terms: u32) -> Float<f32>
The hyperbolic cosine calculated using Taylor series expansion via the exponent formula.
§Formulation
$$ \cosh(x) = \frac{e^x + e^{-x}}{2} $$
See the exp_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn tanh_series(self, terms: u32) -> Float<f32>
pub const fn tanh_series(self, terms: u32) -> Float<f32>
Computes the hyperbolic tangent using Taylor series expansion of hyperbolic sine and cosine.
§Formulation
$$ \tanh(x) = \frac{\sinh(x)}{\cosh(x)} $$
See the exp_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn asinh_series(self, terms: u32) -> Float<f32>
pub const fn asinh_series(self, terms: u32) -> Float<f32>
Computes the inverse hyperbolic sine using the natural logarithm definition.
§Formulation
$$ \text{asinh}(x) = \ln(x + \sqrt{x^2 + 1}) $$
See also ln_series_terms
.
Sourcepub const fn acosh_series(self, terms: u32) -> Float<f32>
pub const fn acosh_series(self, terms: u32) -> Float<f32>
Computes the inverse hyperbolic cosine using the natural logarithm definition.
§Formulation
$$ \text{acosh}(x) = \ln(x + \sqrt{x^2 - 1}) $$
See also ln_series_terms
.
Sourcepub const fn atanh_series(self, terms: u32) -> Float<f32>
pub const fn atanh_series(self, terms: u32) -> Float<f32>
Computes the inverse hyperbolic tangent using the natural logarithm definition.
§Formulation
$$ \text{atanh}(x) = \frac{1}{2} \ln\left(\frac{1 + x}{1 - x}\right) $$
See also ln_series_terms
.
Source§impl Float<f64>
Available on crate feature _float_f64
only.
impl Float<f64>
_float_f64
only.§Common methods with or without std
or libm
.
Implemented using Taylor series.
Sourcepub const fn powf_series(self, y: f64, ln_x_terms: u32) -> Float<f64>
pub const fn powf_series(self, y: f64, ln_x_terms: u32) -> Float<f64>
Raises itself to the y
floating point power using the Taylor series via the
exp
and ln
functions.
§Formulation
$$ \large x^y = e^{y \cdot \ln(x)} $$
See also ln_series_terms
.
The terms for the exponential function are calculated using
exp_series_terms
using $y\cdot\ln(x)$.
Sourcepub const fn exp_series(self, terms: u32) -> Float<f64>
pub const fn exp_series(self, terms: u32) -> Float<f64>
Computes the exponential function $e^x$ using Taylor series expansion.
§Formulation
$$ e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots $$ For values $ x < 0 $ it uses the identity: $$ e^x = \frac{1}{e^-x} $$
See also exp_series_terms
.
Sourcepub const fn exp_series_terms(self) -> u32 ⓘ
pub const fn exp_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for exp_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 5
± 0.100 → 6 10
± 1.000 → 11 18
± 10.000 → 32 46
± 20.000 → 49 68
± 50.000 → 92 119
± 88.722 → 143 177 (max for f32 == f32::MAX.ln())
± 150.000 → --- 261
± 300.000 → --- 453
± 500.000 → --- 692
± 709.782 → --- 938 (max for f64 == f64:MAX.ln())
Sourcepub const fn exp_m1_series(self, terms: u32) -> Float<f64>
pub const fn exp_m1_series(self, terms: u32) -> Float<f64>
Calculates $ e^x - 1 $ using the Taylor series expansion.
§Formulation
$$
e^x -1 = x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots $$
For values $ x < 0 $ it uses the identity: $$ e^x -1 = -\frac{1}{e^{-x}+1} $$
For values $ x > 0.001 $ it uses exp_series
.
See also exp_series_terms
.
Sourcepub const fn exp2_series(self, terms: u32) -> Float<f64>
pub const fn exp2_series(self, terms: u32) -> Float<f64>
Calculates $ 2^x $ using the Taylor series expansion.
§Formulation
The series based on the formula $ 2^x = e^{x \ln(2)} $ is: $$ 2^x = 1 + x \ln(2) + \frac{(x \ln(2))^2}{2!} + \frac{(x \ln(2))^3}{3!} + \frac{(x \ln(2))^4}{4!} + \cdots $$
The maximum values with a representable result are:
127 for f32
and 1023 for f64
.
Sourcepub const fn exp2_series_terms(self) -> u32 ⓘ
pub const fn exp2_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for exp2_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.3 → 8 13
± 3.0 → 15 25
± 7.0 → 22 34
± 15.0 → 34 49
± 31.0 → 52 71
± 63.0 → 84 110
± 127.999 → 144 178 (max for f32)
± 255.0 → --- 298
± 511.0 → --- 520
± 1023.999 → --- 939 (max for f64)
Sourcepub const fn ln_series(self, terms: u32) -> Float<f64>
pub const fn ln_series(self, terms: u32) -> Float<f64>
Computes the natural logarithm of self
using a Taylor-Mercator series expansion.
This method is more efficient for values of self
near 1. Values too
small or too big could be impractical to calculate with precision.
§Formulation
$$ \ln(x) = 2 \left( \frac{x-1}{x+1} + \frac{1}{3} \left( \frac{x-1}{x+1} \right)^3 + \frac{1}{5} \left( \frac{x-1}{x+1} \right)^5 + \cdots \right) $$
See also ln_series_terms
.
Sourcepub const fn ln_1p_series(self, terms: u32) -> Float<f64>
pub const fn ln_1p_series(self, terms: u32) -> Float<f64>
Computes the natural logarithm of 1 + self
using a Taylor-Mercator series expansion.
This method is more efficient for values of self
near 0.
Values too small or too big could be impractical to calculate with precision.
Returns ln(1+self)
more accurately
than if the operations were performed separately.
See also ln_series_terms
.
Sourcepub const fn log_series(self, base: f64, terms: u32) -> Float<f64>
pub const fn log_series(self, base: f64, terms: u32) -> Float<f64>
Computes the logarithm to the given base
using the change of base formula.
§Formulation
$$ \log_{\text{base}}(x) = \frac{\ln(x)}{\ln(\text{base})} $$
See also ln_series_terms
.
Sourcepub const fn log2_series(self, terms: u32) -> Float<f64>
pub const fn log2_series(self, terms: u32) -> Float<f64>
Computes the base-2 logarithm using the change of base formula.
§Formulation
$$ \log_{2}(x) = \frac{\ln(x)}{\ln(2)} $$
See also ln_series_terms
.
Sourcepub const fn log10_series(self, terms: u32) -> Float<f64>
pub const fn log10_series(self, terms: u32) -> Float<f64>
Computes the base-10 logarithm using the change of base formula.
§Formulation
$$ \log_{10}(x) = \frac{\ln(x)}{\ln(10)} $$
See also ln_series_terms
.
Sourcepub const fn ln_series_terms(self) -> u32 ⓘ
pub const fn ln_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for exp2_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
--------------------------
± 0.00001 → 81181 536609
± 0.0001 → 12578 59174
± 0.001 → 1923 6639
± 0.01. → 245 720
± 0.1 → 32 80
± 0.5 → 8 17
± 1. → 1 1
± 2. → 8 17
± 10. → 32 80
± 100. → 245 720
± 1000. → 1923 6639
± 10000. → 12578 59174
± 100000. → 81181 536609
/// ```
Sourcepub const fn sin_series(self, terms: u32) -> Float<f64>
pub const fn sin_series(self, terms: u32) -> Float<f64>
The sine calculated using Taylor series expansion.
§Formulation
$$ \sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots $$
This Taylor series converges relatively quickly and uniformly
over the entire domain.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 4 6
± 0.300 → 5 7
± 0.500 → 5 8
± 0.700 → 6 9
± 0.900 → 6 10
± 0.999 → 6 10
Sourcepub const fn cos_series(self, terms: u32) -> Float<f64>
pub const fn cos_series(self, terms: u32) -> Float<f64>
Computes the cosine using taylor series expansion.
§Formulation
$$ \cos(x) = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots $$
This Taylor series converges relatively quickly and uniformly
over the entire domain.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 4 6
± 0.300 → 5 8
± 0.500 → 6 9
± 0.700 → 6 10
± 0.900 → 7 10
± 0.999 → 7 11
Sourcepub const fn sin_cos_series(self, terms: u32) -> (Float<f64>, Float<f64>) ⓘ
pub const fn sin_cos_series(self, terms: u32) -> (Float<f64>, Float<f64>) ⓘ
Computes the sine and the cosine using Taylor series expansion.
Sourcepub const fn tan_series(self, terms: u32) -> Float<f64>
pub const fn tan_series(self, terms: u32) -> Float<f64>
Computes the tangent using Taylor series expansion of sine and cosine.
§Formulation
$$ \tan(x) = \frac{\sin(x)}{\cos(x)} $$
The tangent function has singularities and is not defined for
cos(x) = 0
. This function clamps self
within an appropriate range
to avoid such issues.
The Taylor series for sine and cosine converge relatively quickly
and uniformly over the entire domain.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 4 6
± 0.300 → 5 8
± 0.500 → 6 9
± 0.700 → 6 10
± 0.900 → 7 10
± 0.999 → 7 11
Sourcepub const fn asin_series(self, terms: u32) -> Float<f64>
pub const fn asin_series(self, terms: u32) -> Float<f64>
Computes the arcsine using Taylor series expansion.
§Formulation
$$ \arcsin(x) = x + \left( \frac{1}{2} \right) \frac{x^3}{3} + \left( \frac{1}{2} \cdot \frac{3}{4} \right) \frac{x^5}{5} + \left( \frac{1}{2} \cdot \frac{3}{4} \cdot \frac{5}{6} \right) \frac{x^7}{7} + \cdots $$
asin is undefined for $ |x| > 1 $ and in that case returns NaN
.
The series converges more slowly near the edges of the domain
(i.e., as self
approaches -1 or 1). For more accurate results,
especially near these boundary values, a higher number of terms
may be necessary.
See also asin_series_terms
.
Sourcepub const fn asin_series_terms(self) -> u32 ⓘ
pub const fn asin_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for asin_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 5 9
± 0.300 → 7 15
± 0.500 → 10 24
± 0.700 → 18 44
± 0.900 → 47 134
± 0.990 → 333 1235
± 0.999 → 1989 10768
Sourcepub const fn acos_series(self, terms: u32) -> Float<f64>
pub const fn acos_series(self, terms: u32) -> Float<f64>
Computes the arccosine using the Taylor expansion of arcsine.
§Formulation
$$ \arccos(x)=2π-arcsin(x) $$
See the asin_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn acos_series_terms(self) -> u32 ⓘ
pub const fn acos_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for acos_series
to reach a stable result based on the input value.
The table is the same as asin_series_terms
.
Sourcepub const fn atan_series(self, terms: u32) -> Float<f64>
pub const fn atan_series(self, terms: u32) -> Float<f64>
Computes the arctangent using Taylor series expansion.
§Formulation
$$ \arctan(x) = x - \frac{x^3}{3} + \frac{x^5}{5} - \frac{x^7}{7} + \cdots $$ For values $ |x| > 1 $ it uses the identity: $$ \arctan(x) = \frac{\pi}{2} - \arctan(\frac{1}{x}) $$
The series converges more slowly near the edges of the domain
(i.e., as self
approaches -1 or 1). For more accurate results,
especially near these boundary values, a higher number of terms
may be necessary.
See also atan_series_terms
.
Sourcepub const fn atan_series_terms(self) -> u32 ⓘ
pub const fn atan_series_terms(self) -> u32 ⓘ
Determines the number of terms needed for atan_series
to reach a stable result based on the input value.
The following table shows the required number of terms
needed
to reach the most precise result for both f32
and f64
:
value t_f32 t_f64
-------------------------
± 0.001 → 3 4
± 0.100 → 5 9
± 0.300 → 7 15
± 0.500 → 12 26
± 0.700 → 20 47
± 0.900 → 61 152
± 0.990 → 518 1466
± 0.999 → 4151 13604
Sourcepub const fn atan2_series(self, other: f64, terms: u32) -> Float<f64>
pub const fn atan2_series(self, other: f64, terms: u32) -> Float<f64>
Computes the four quadrant arctangent of self
and other
using Taylor series expansion.
See also atan_series_terms
.
Sourcepub const fn sinh_series(self, terms: u32) -> Float<f64>
pub const fn sinh_series(self, terms: u32) -> Float<f64>
The hyperbolic sine calculated using Taylor series expansion via the exponent formula.
§Formulation
$$ \sinh(x) = \frac{e^x - e^{-x}}{2} $$
See the exp_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn cosh_series(self, terms: u32) -> Float<f64>
pub const fn cosh_series(self, terms: u32) -> Float<f64>
The hyperbolic cosine calculated using Taylor series expansion via the exponent formula.
§Formulation
$$ \cosh(x) = \frac{e^x + e^{-x}}{2} $$
See the exp_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn tanh_series(self, terms: u32) -> Float<f64>
pub const fn tanh_series(self, terms: u32) -> Float<f64>
Computes the hyperbolic tangent using Taylor series expansion of hyperbolic sine and cosine.
§Formulation
$$ \tanh(x) = \frac{\sinh(x)}{\cosh(x)} $$
See the exp_series_terms
table for
information about the number of terms
needed.
Sourcepub const fn asinh_series(self, terms: u32) -> Float<f64>
pub const fn asinh_series(self, terms: u32) -> Float<f64>
Computes the inverse hyperbolic sine using the natural logarithm definition.
§Formulation
$$ \text{asinh}(x) = \ln(x + \sqrt{x^2 + 1}) $$
See also ln_series_terms
.
Sourcepub const fn acosh_series(self, terms: u32) -> Float<f64>
pub const fn acosh_series(self, terms: u32) -> Float<f64>
Computes the inverse hyperbolic cosine using the natural logarithm definition.
§Formulation
$$ \text{acosh}(x) = \ln(x + \sqrt{x^2 - 1}) $$
See also ln_series_terms
.
Sourcepub const fn atanh_series(self, terms: u32) -> Float<f64>
pub const fn atanh_series(self, terms: u32) -> Float<f64>
Computes the inverse hyperbolic tangent using the natural logarithm definition.
§Formulation
$$ \text{atanh}(x) = \frac{1}{2} \ln\left(\frac{1 + x}{1 - x}\right) $$
See also ln_series_terms
.
Trait Implementations§
Source§impl<'s, 'o> Add<&'o Float<f32>> for &'s Float<f32>
Available on crate feature _float_f32
only.
impl<'s, 'o> Add<&'o Float<f32>> for &'s Float<f32>
_float_f32
only.Source§impl<'s, 'o> Add<&'o Float<f64>> for &'s Float<f64>
Available on crate feature _float_f64
only.
impl<'s, 'o> Add<&'o Float<f64>> for &'s Float<f64>
_float_f64
only.Source§impl<'o> AddAssign<&'o f32> for Float<f32>
Available on crate feature _float_f32
only.
impl<'o> AddAssign<&'o f32> for Float<f32>
_float_f32
only.Source§fn add_assign(&mut self, other: &'o f32)
fn add_assign(&mut self, other: &'o f32)
+=
operation. Read moreSource§impl<'o> AddAssign<&'o f64> for Float<f64>
Available on crate feature _float_f64
only.
impl<'o> AddAssign<&'o f64> for Float<f64>
_float_f64
only.Source§fn add_assign(&mut self, other: &'o f64)
fn add_assign(&mut self, other: &'o f64)
+=
operation. Read moreSource§impl AddAssign<f32> for Float<f32>
Available on crate feature _float_f32
only.
impl AddAssign<f32> for Float<f32>
_float_f32
only.Source§fn add_assign(&mut self, other: f32)
fn add_assign(&mut self, other: f32)
+=
operation. Read moreSource§impl AddAssign<f64> for Float<f64>
Available on crate feature _float_f64
only.
impl AddAssign<f64> for Float<f64>
_float_f64
only.Source§fn add_assign(&mut self, other: f64)
fn add_assign(&mut self, other: f64)
+=
operation. Read moreSource§impl<'s, 'o> Div<&'o Float<f32>> for &'s Float<f32>
Available on crate feature _float_f32
only.
impl<'s, 'o> Div<&'o Float<f32>> for &'s Float<f32>
_float_f32
only.Source§impl<'s, 'o> Div<&'o Float<f64>> for &'s Float<f64>
Available on crate feature _float_f64
only.
impl<'s, 'o> Div<&'o Float<f64>> for &'s Float<f64>
_float_f64
only.Source§impl<'o> DivAssign<&'o f32> for Float<f32>
Available on crate feature _float_f32
only.
impl<'o> DivAssign<&'o f32> for Float<f32>
_float_f32
only.Source§fn div_assign(&mut self, other: &'o f32)
fn div_assign(&mut self, other: &'o f32)
/=
operation. Read moreSource§impl<'o> DivAssign<&'o f64> for Float<f64>
Available on crate feature _float_f64
only.
impl<'o> DivAssign<&'o f64> for Float<f64>
_float_f64
only.Source§fn div_assign(&mut self, other: &'o f64)
fn div_assign(&mut self, other: &'o f64)
/=
operation. Read moreSource§impl DivAssign<f32> for Float<f32>
Available on crate feature _float_f32
only.
impl DivAssign<f32> for Float<f32>
_float_f32
only.Source§fn div_assign(&mut self, other: f32)
fn div_assign(&mut self, other: f32)
/=
operation. Read moreSource§impl DivAssign<f64> for Float<f64>
Available on crate feature _float_f64
only.
impl DivAssign<f64> for Float<f64>
_float_f64
only.Source§fn div_assign(&mut self, other: f64)
fn div_assign(&mut self, other: f64)
/=
operation. Read moreSource§impl<'s, 'o> Mul<&'o Float<f32>> for &'s Float<f32>
Available on crate feature _float_f32
only.
impl<'s, 'o> Mul<&'o Float<f32>> for &'s Float<f32>
_float_f32
only.Source§impl<'s, 'o> Mul<&'o Float<f64>> for &'s Float<f64>
Available on crate feature _float_f64
only.
impl<'s, 'o> Mul<&'o Float<f64>> for &'s Float<f64>
_float_f64
only.Source§impl<'o> MulAssign<&'o f32> for Float<f32>
Available on crate feature _float_f32
only.
impl<'o> MulAssign<&'o f32> for Float<f32>
_float_f32
only.Source§fn mul_assign(&mut self, other: &'o f32)
fn mul_assign(&mut self, other: &'o f32)
*=
operation. Read moreSource§impl<'o> MulAssign<&'o f64> for Float<f64>
Available on crate feature _float_f64
only.
impl<'o> MulAssign<&'o f64> for Float<f64>
_float_f64
only.Source§fn mul_assign(&mut self, other: &'o f64)
fn mul_assign(&mut self, other: &'o f64)
*=
operation. Read moreSource§impl MulAssign<f32> for Float<f32>
Available on crate feature _float_f32
only.
impl MulAssign<f32> for Float<f32>
_float_f32
only.Source§fn mul_assign(&mut self, other: f32)
fn mul_assign(&mut self, other: f32)
*=
operation. Read moreSource§impl MulAssign<f64> for Float<f64>
Available on crate feature _float_f64
only.
impl MulAssign<f64> for Float<f64>
_float_f64
only.Source§fn mul_assign(&mut self, other: f64)
fn mul_assign(&mut self, other: f64)
*=
operation. Read moreSource§impl<T: PartialOrd> PartialOrd<T> for Float<T>
impl<T: PartialOrd> PartialOrd<T> for Float<T>
Source§impl<T: PartialOrd> PartialOrd for Float<T>
impl<T: PartialOrd> PartialOrd for Float<T>
Source§impl<'s, 'o> Rem<&'o Float<f32>> for &'s Float<f32>
Available on crate feature _float_f32
only.
impl<'s, 'o> Rem<&'o Float<f32>> for &'s Float<f32>
_float_f32
only.Source§impl<'s, 'o> Rem<&'o Float<f64>> for &'s Float<f64>
Available on crate feature _float_f64
only.
impl<'s, 'o> Rem<&'o Float<f64>> for &'s Float<f64>
_float_f64
only.Source§impl<'o> RemAssign<&'o f32> for Float<f32>
Available on crate feature _float_f32
only.
impl<'o> RemAssign<&'o f32> for Float<f32>
_float_f32
only.Source§fn rem_assign(&mut self, other: &'o f32)
fn rem_assign(&mut self, other: &'o f32)
%=
operation. Read moreSource§impl<'o> RemAssign<&'o f64> for Float<f64>
Available on crate feature _float_f64
only.
impl<'o> RemAssign<&'o f64> for Float<f64>
_float_f64
only.Source§fn rem_assign(&mut self, other: &'o f64)
fn rem_assign(&mut self, other: &'o f64)
%=
operation. Read moreSource§impl RemAssign<f32> for Float<f32>
Available on crate feature _float_f32
only.
impl RemAssign<f32> for Float<f32>
_float_f32
only.Source§fn rem_assign(&mut self, other: f32)
fn rem_assign(&mut self, other: f32)
%=
operation. Read moreSource§impl RemAssign<f64> for Float<f64>
Available on crate feature _float_f64
only.
impl RemAssign<f64> for Float<f64>
_float_f64
only.Source§fn rem_assign(&mut self, other: f64)
fn rem_assign(&mut self, other: f64)
%=
operation. Read moreSource§impl<'s, 'o> Sub<&'o Float<f32>> for &'s Float<f32>
Available on crate feature _float_f32
only.
impl<'s, 'o> Sub<&'o Float<f32>> for &'s Float<f32>
_float_f32
only.Source§impl<'s, 'o> Sub<&'o Float<f64>> for &'s Float<f64>
Available on crate feature _float_f64
only.
impl<'s, 'o> Sub<&'o Float<f64>> for &'s Float<f64>
_float_f64
only.Source§impl<'o> SubAssign<&'o f32> for Float<f32>
Available on crate feature _float_f32
only.
impl<'o> SubAssign<&'o f32> for Float<f32>
_float_f32
only.Source§fn sub_assign(&mut self, other: &'o f32)
fn sub_assign(&mut self, other: &'o f32)
-=
operation. Read moreSource§impl<'o> SubAssign<&'o f64> for Float<f64>
Available on crate feature _float_f64
only.
impl<'o> SubAssign<&'o f64> for Float<f64>
_float_f64
only.Source§fn sub_assign(&mut self, other: &'o f64)
fn sub_assign(&mut self, other: &'o f64)
-=
operation. Read moreSource§impl SubAssign<f32> for Float<f32>
Available on crate feature _float_f32
only.
impl SubAssign<f32> for Float<f32>
_float_f32
only.Source§fn sub_assign(&mut self, other: f32)
fn sub_assign(&mut self, other: f32)
-=
operation. Read moreSource§impl SubAssign<f64> for Float<f64>
Available on crate feature _float_f64
only.
impl SubAssign<f64> for Float<f64>
_float_f64
only.Source§fn sub_assign(&mut self, other: f64)
fn sub_assign(&mut self, other: f64)
-=
operation. Read moreimpl<T: Copy> Copy for Float<T>
Auto Trait Implementations§
impl<T> Freeze for Float<T>where
T: Freeze,
impl<T> RefUnwindSafe for Float<T>where
T: RefUnwindSafe,
impl<T> Send for Float<T>where
T: Send,
impl<T> Sync for Float<T>where
T: Sync,
impl<T> Unpin for Float<T>where
T: Unpin,
impl<T> UnwindSafe for Float<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.