Skip to main content

F32Grid

Struct F32Grid 

Source
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: u32

One 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

Source

pub fn truncate_mask(&self) -> u32

Clears the mantissa bits the param does not carry, truncating a bit pattern onto the grid.

Source

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.

Trait Implementations§

Source§

impl Clone for F32Grid

Source§

fn clone(&self) -> F32Grid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for F32Grid

Source§

impl Debug for F32Grid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for F32Grid

Source§

fn eq(&self, other: &F32Grid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for F32Grid

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.