Trait opendp::traits::Float

source ·
pub trait Float: Number + Float + InherentNull + InfLn + InfLn1P + InfLog2 + InfExp + InfExpM1 + InfPow + InfSqrt + FloatBits + ExactIntCast<Self::Bits> + RoundCast<f64> { }
Expand description

Floating-point types.

Examples: f32, f64

This trait lists many traits that are implemented for floating-point types. It is a shorthand to provide broad floating-point functionality to a generic type, without polluting trait bounds with a large number of highly-specific traits.

Refer to the constituent traits to see proof definitions on methods.

Example

use opendp::traits::Float;
fn test_func<T: Float>(value: T) {
    // can be debugged, as Integer inherits all traits from Primitive:
    println!("{value:?}");

    // supports arithmetic and has numerical properties
    assert_eq!(T::zero().inf_mul(&value).ok(), Some(T::zero()));
}

test_func(3.14159);

Implementors§