micromath icon indicating copy to clipboard operation
micromath copied to clipboard

F32::inv fails for large numbers

Open usbalbin opened this issue 1 year ago • 0 comments

F32::inv fails for values larger than f32::from_bits(0x7F00_0000) ~= 1.7014118e+38

80 ERROR panicked at /home/decahe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/micromath-2.1.0/src/float/inv.rs:10:29:
attempt to subtract with overflow
└─ panic_probe::print_defmt::print @ /home/decahe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/panic-probe-0.3.1/src/lib.rs:104

float/inv.rs:

/// Fast approximation of `1/x`.
pub fn inv(self) -> Self {
    Self(f32::from_bits(0x7f00_0000 - self.0.to_bits()))
}

usbalbin avatar Mar 25 '24 15:03 usbalbin