Module floating_point

Source

Structsยง

FiniteF32
An immutable, finite f32.
NonZeroPositiveF32
An immutable, finite f32 that is known to be > 0.
NormalizedF32
An immutable, finite f32 in a 0..=1 range.
NormalizedF32Exclusive
An immutable f32 that is larger than 0 but less then 1.

Constantsยง

FLOAT_PI ๐Ÿ”’
MAX_I32_FITS_IN_F32 ๐Ÿ”’
MIN_I32_FITS_IN_F32 ๐Ÿ”’

Traitsยง

SaturateCast
Custom float to integer conversion routines.
SaturateRound
Custom float to integer rounding routines.

Functionsยง

f32_as_2s_compliment ๐Ÿ”’
Return the float as a 2s compliment int. Just to be used to compare floats to each other or against positive float-bit-constants (like 0). This does not return the int equivalent of the float, just something cheaper for compares-only.
sign_bit_to_2s_compliment ๐Ÿ”’
Convert a sign-bit int (i.e. float interpreted as int) into a 2s compliement int. This also converts -0 (0x80000000) to 0. Doing this to a float allows it to be compared using normal C operators (<, <=, etc.)