pub struct Fixed(/* private fields */);
Expand description
32-bit signed fixed point number with 16 bits of fraction.
Implementations§
Source§impl Fixed
impl Fixed
Sourcepub const fn from_bits(bits: i32) -> Self
pub const fn from_bits(bits: i32) -> Self
Creates a new fixed point value from the underlying bit representation.
Sourcepub fn wrapping_add(self, other: Self) -> Self
pub fn wrapping_add(self, other: Self) -> Self
Wrapping addition.
Sourcepub const fn saturating_add(self, other: Self) -> Self
pub const fn saturating_add(self, other: Self) -> Self
Saturating addition.
Sourcepub fn checked_add(self, other: Self) -> Option<Self>
pub fn checked_add(self, other: Self) -> Option<Self>
Checked addition.
Sourcepub const fn wrapping_sub(self, other: Self) -> Self
pub const fn wrapping_sub(self, other: Self) -> Self
Wrapping substitution.
Sourcepub const fn saturating_sub(self, other: Self) -> Self
pub const fn saturating_sub(self, other: Self) -> Self
Saturating substitution.
Sourcepub const fn to_be_bytes(self) -> [u8; 4]
pub const fn to_be_bytes(self) -> [u8; 4]
The representation of this number as a big-endian byte array.
Source§impl Fixed
impl Fixed
Sourcepub const fn to_i32(self) -> i32
pub const fn to_i32(self) -> i32
Converts a 16.16 fixed point value to a 32 bit integer, rounding off the fractional bits.
Sourcepub const fn to_f26dot6(self) -> F26Dot6
pub const fn to_f26dot6(self) -> F26Dot6
Converts a 16.16 to 26.6 fixed point value.
Sourcepub const fn to_f2dot14(self) -> F2Dot14
pub const fn to_f2dot14(self) -> F2Dot14
Converts a 16.16 to 2.14 fixed point value.
This specific conversion is defined by the spec: https://learn.microsoft.com/en-us/typography/opentype/spec/otvaroverview#coordinate-scales-and-normalization
“5. Convert the final, normalized 16.16 coordinate value to 2.14 by this method: add 0x00000002, and sign-extend shift to the right by 2.”
Trait Implementations§
Source§impl AddAssign for Fixed
impl AddAssign for Fixed
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moreSource§impl<'de> Deserialize<'de> for Fixed
impl<'de> Deserialize<'de> for Fixed
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl DivAssign for Fixed
impl DivAssign for Fixed
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moreSource§impl MulAssign for Fixed
impl MulAssign for Fixed
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moreSource§impl Ord for Fixed
impl Ord for Fixed
Source§impl PartialOrd for Fixed
impl PartialOrd for Fixed
Source§impl SubAssign for Fixed
impl SubAssign for Fixed
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read moreimpl AnyBitPattern for Fixed
impl Copy for Fixed
impl Eq for Fixed
impl NoUninit for Fixed
impl StructuralPartialEq for Fixed
Auto Trait Implementations§
impl Freeze for Fixed
impl RefUnwindSafe for Fixed
impl Send for Fixed
impl Sync for Fixed
impl Unpin for Fixed
impl UnwindSafe for Fixed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.