pub struct F32Grid {
pub bit_step: u32,
pub subnormals: Option<SubnormalRange>,
}Expand description
A narrower float format’s grid, laid over the f32 bit pattern.
f32 carries every param this exists for exactly, so the grid can be walked there rather than
through the storage type. A value representable in the param leaves the low f32 mantissa bits
zero, so one param ulp is an increment at that position and the carry into the exponent falls
out on its own. Working in f32 also keeps the grid available to backends with no narrow integer,
and to builds without the fp8 feature.
Fields§
§bit_step: u32One step up in the normal range, as an increment on the f32 bit pattern.
subnormals: Option<SubnormalRange>The param’s subnormals, for the formats whose subnormals land in f32’s normal range.
Implementations§
Source§impl F32Grid
impl F32Grid
Sourcepub fn truncate_mask(&self) -> u32
pub fn truncate_mask(&self) -> u32
Clears the mantissa bits the param does not carry, truncating a bit pattern onto the grid.
Sourcepub fn round_up_bias(&self) -> u32
pub fn round_up_bias(&self) -> u32
Added to a bit pattern before truncate_mask to turn that truncation
into a round up. The carry it can produce is only safe below the param’s maximum, which is
why callers saturate there first.