Skip to main content

Float

Trait Float 

Source
pub trait Float:
    Sealed
    + Copy
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self> {
    const IS_F64: bool;

    // Required methods
    fn from_f32(v: f32) -> Self;
    fn from_f64(v: f64) -> Self;
    fn to_f32(self) -> f32;
    fn to_f64(self) -> f64;
    fn exp(self) -> Self;
    fn log10(self) -> Self;
    fn powf(self, exp: Self) -> Self;
}
Expand description

Math on f32 or f64 (gains, freqs, coefficients — not necessarily samples).

Prefer Sample for AudioBuffer<S> and similar buffer bounds.

Required Associated Constants§

Source

const IS_F64: bool

true for f64. Sealed, so equal IS_F64 means same type.

Required Methods§

Source

fn from_f32(v: f32) -> Self

Widen f32 → this precision (identity on f32).

Source

fn from_f64(v: f64) -> Self

Narrow f64 → this precision. Debug-asserts non-NaN on f32 (NaN in the audio path is always a bug). Release keeps NaN via as.

Source

fn to_f32(self) -> f32

Narrow to f32 (same NaN debug-assert as Self::from_f64).

Source

fn to_f64(self) -> f64

Widen to f64.

Source

fn exp(self) -> Self

Source

fn log10(self) -> Self

Source

fn powf(self, exp: Self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Float for f32

Source§

const IS_F64: bool = false

Source§

fn from_f32(v: f32) -> Self

Source§

fn from_f64(v: f64) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn to_f64(self) -> f64

Source§

fn exp(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn powf(self, exp: Self) -> Self

Source§

impl Float for f64

Source§

const IS_F64: bool = true

Source§

fn from_f32(v: f32) -> Self

Source§

fn from_f64(v: f64) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn to_f64(self) -> f64

Source§

fn exp(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn powf(self, exp: Self) -> Self

Implementors§