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) -> Fixed
pub const fn from_bits(bits: i32) -> Fixed
Creates a new fixed point value from the underlying bit representation.
Sourcepub const fn floor(self) -> Fixed
pub const fn floor(self) -> Fixed
Returns the largest integer less than or equal to the number.
Sourcepub fn wrapping_add(self, other: Fixed) -> Fixed
pub fn wrapping_add(self, other: Fixed) -> Fixed
Wrapping addition.
Sourcepub const fn saturating_add(self, other: Fixed) -> Fixed
pub const fn saturating_add(self, other: Fixed) -> Fixed
Saturating addition.
Sourcepub fn checked_add(self, other: Fixed) -> Option<Fixed>
pub fn checked_add(self, other: Fixed) -> Option<Fixed>
Checked addition.
Sourcepub const fn wrapping_sub(self, other: Fixed) -> Fixed
pub const fn wrapping_sub(self, other: Fixed) -> Fixed
Wrapping substitution.
Sourcepub const fn saturating_sub(self, other: Fixed) -> Fixed
pub const fn saturating_sub(self, other: Fixed) -> Fixed
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 from_i32(i: i32) -> Fixed
pub const fn from_i32(i: i32) -> Fixed
Creates a 16.16 fixed point value from a 32 bit integer.
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: Fixed)
fn add_assign(&mut self, other: Fixed)
+= operation. Read moreimpl Copy for Fixed
Source§impl DivAssign for Fixed
impl DivAssign for Fixed
Source§fn div_assign(&mut self, rhs: Fixed)
fn div_assign(&mut self, rhs: Fixed)
/= operation. Read moreimpl Eq for Fixed
Source§impl MulAssign for Fixed
impl MulAssign for Fixed
Source§fn mul_assign(&mut self, rhs: Fixed)
fn mul_assign(&mut self, rhs: Fixed)
*= operation. Read more