Skip to content

feat: impl lossy_from(f64) #4

@OliverNChalk

Description

@OliverNChalk

Example for how to extract the mantissa & exponent:

fn raw_mantissa_and_exponent<T: PrimitiveFloat>(x: T) -> (u64, u64) {
    let bits = x.to_bits();
    let mantissa = bits.mod_power_of_2(T::MANTISSA_WIDTH);
    let exponent: u64 = (bits >> T::MANTISSA_WIDTH).exact_into();
    let exponent = exponent.mod_power_of_2(T::EXPONENT_WIDTH);
    (mantissa, exponent)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions