pub struct Fixed(/* private fields */);Expand description
A signed 24.8 fixed-point number used in the wayland protocol.
This is a signed decimal type which offers a sign bit, 23 bits of integer precision and 8 bits of decimal precision.
§Arithmetic operations
This type implements all of the usual arithmetic operations for numbers. On overflow, they behave like the standard library operations except that multiplication and division always use wrapping semantics.
Implementations§
Source§impl Fixed
impl Fixed
Sourcepub const NEGATIVE_EPSILON: Self
pub const NEGATIVE_EPSILON: Self
The largest negative Fixed.
Sourcepub const fn from_wire(val: i32) -> Self
pub const fn from_wire(val: i32) -> Self
Creates a Fixed from the raw bits that appear in the wire protocol.
Sourcepub const fn to_wire(self) -> i32
pub const fn to_wire(self) -> i32
Converts this Fixed to the bits that should be set in the wire protocol.
Sourcepub const fn to_f32_lossy(self) -> f32
pub const fn to_f32_lossy(self) -> f32
Sourcepub const fn from_f64_lossy(val: f64) -> Self
pub const fn from_f64_lossy(val: f64) -> Self
Creates a Fixed from an f64.
If the value cannot be represented exactly, the behavior is as when an f64 is cast to an
integer. That is
- Values are rounded towards 0.
NaNreturnsFixed::ZERO.- Values larger than the maximum return
Fixed::MAX. - Values smaller than the minimum return
Fixed::MIN.
Sourcepub const fn from_f32_lossy(val: f32) -> Self
pub const fn from_f32_lossy(val: f32) -> Self
Creates a Fixed from an f32.
The conversion behavior is the same as for Fixed::from_f64_lossy.
Sourcepub const fn from_i32_saturating(val: i32) -> Self
pub const fn from_i32_saturating(val: i32) -> Self
Creates a Fixed from an i32.
Values outside of the representable range are clamped to Fixed::MIN and Fixed::MAX.
Sourcepub const fn from_i64_saturating(val: i64) -> Self
pub const fn from_i64_saturating(val: i64) -> Self
Creates a Fixed from an i64.
Values outside of the representable range are clamped to Fixed::MIN and Fixed::MAX.
Sourcepub const fn to_i32_round_towards_nearest(self) -> i32
pub const fn to_i32_round_towards_nearest(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards the nearest integer and half-way away from 0.
Sourcepub const fn to_i32_round_towards_zero(self) -> i32
pub const fn to_i32_round_towards_zero(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards zero.
Sourcepub const fn to_i32_floor(self) -> i32
pub const fn to_i32_floor(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards minus infinity.
Sourcepub const fn to_i32_ceil(self) -> i32
pub const fn to_i32_ceil(self) -> i32
Converts this Fixed to an i32.
The conversion rounds towards infinity.
Trait Implementations§
Source§impl AddAssign for Fixed
impl AddAssign for Fixed
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl BitAndAssign for Fixed
impl BitAndAssign for Fixed
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for Fixed
impl BitOrAssign for Fixed
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXorAssign for Fixed
impl BitXorAssign for Fixed
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§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 RemAssign for Fixed
impl RemAssign for Fixed
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moreSource§impl ShlAssign<&i128> for Fixed
impl ShlAssign<&i128> for Fixed
Source§fn shl_assign(&mut self, rhs: &i128)
fn shl_assign(&mut self, rhs: &i128)
<<= operation. Read moreSource§impl ShlAssign<&i16> for Fixed
impl ShlAssign<&i16> for Fixed
Source§fn shl_assign(&mut self, rhs: &i16)
fn shl_assign(&mut self, rhs: &i16)
<<= operation. Read moreSource§impl ShlAssign<&i32> for Fixed
impl ShlAssign<&i32> for Fixed
Source§fn shl_assign(&mut self, rhs: &i32)
fn shl_assign(&mut self, rhs: &i32)
<<= operation. Read moreSource§impl ShlAssign<&i64> for Fixed
impl ShlAssign<&i64> for Fixed
Source§fn shl_assign(&mut self, rhs: &i64)
fn shl_assign(&mut self, rhs: &i64)
<<= operation. Read moreSource§impl ShlAssign<&i8> for Fixed
impl ShlAssign<&i8> for Fixed
Source§fn shl_assign(&mut self, rhs: &i8)
fn shl_assign(&mut self, rhs: &i8)
<<= operation. Read moreSource§impl ShlAssign<&isize> for Fixed
impl ShlAssign<&isize> for Fixed
Source§fn shl_assign(&mut self, rhs: &isize)
fn shl_assign(&mut self, rhs: &isize)
<<= operation. Read moreSource§impl ShlAssign<&u128> for Fixed
impl ShlAssign<&u128> for Fixed
Source§fn shl_assign(&mut self, rhs: &u128)
fn shl_assign(&mut self, rhs: &u128)
<<= operation. Read moreSource§impl ShlAssign<&u16> for Fixed
impl ShlAssign<&u16> for Fixed
Source§fn shl_assign(&mut self, rhs: &u16)
fn shl_assign(&mut self, rhs: &u16)
<<= operation. Read moreSource§impl ShlAssign<&u32> for Fixed
impl ShlAssign<&u32> for Fixed
Source§fn shl_assign(&mut self, rhs: &u32)
fn shl_assign(&mut self, rhs: &u32)
<<= operation. Read moreSource§impl ShlAssign<&u64> for Fixed
impl ShlAssign<&u64> for Fixed
Source§fn shl_assign(&mut self, rhs: &u64)
fn shl_assign(&mut self, rhs: &u64)
<<= operation. Read moreSource§impl ShlAssign<&u8> for Fixed
impl ShlAssign<&u8> for Fixed
Source§fn shl_assign(&mut self, rhs: &u8)
fn shl_assign(&mut self, rhs: &u8)
<<= operation. Read moreSource§impl ShlAssign<&usize> for Fixed
impl ShlAssign<&usize> for Fixed
Source§fn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
<<= operation. Read moreSource§impl ShlAssign<i128> for Fixed
impl ShlAssign<i128> for Fixed
Source§fn shl_assign(&mut self, rhs: i128)
fn shl_assign(&mut self, rhs: i128)
<<= operation. Read moreSource§impl ShlAssign<i16> for Fixed
impl ShlAssign<i16> for Fixed
Source§fn shl_assign(&mut self, rhs: i16)
fn shl_assign(&mut self, rhs: i16)
<<= operation. Read moreSource§impl ShlAssign<i32> for Fixed
impl ShlAssign<i32> for Fixed
Source§fn shl_assign(&mut self, rhs: i32)
fn shl_assign(&mut self, rhs: i32)
<<= operation. Read moreSource§impl ShlAssign<i64> for Fixed
impl ShlAssign<i64> for Fixed
Source§fn shl_assign(&mut self, rhs: i64)
fn shl_assign(&mut self, rhs: i64)
<<= operation. Read moreSource§impl ShlAssign<i8> for Fixed
impl ShlAssign<i8> for Fixed
Source§fn shl_assign(&mut self, rhs: i8)
fn shl_assign(&mut self, rhs: i8)
<<= operation. Read moreSource§impl ShlAssign<isize> for Fixed
impl ShlAssign<isize> for Fixed
Source§fn shl_assign(&mut self, rhs: isize)
fn shl_assign(&mut self, rhs: isize)
<<= operation. Read moreSource§impl ShlAssign<u128> for Fixed
impl ShlAssign<u128> for Fixed
Source§fn shl_assign(&mut self, rhs: u128)
fn shl_assign(&mut self, rhs: u128)
<<= operation. Read moreSource§impl ShlAssign<u16> for Fixed
impl ShlAssign<u16> for Fixed
Source§fn shl_assign(&mut self, rhs: u16)
fn shl_assign(&mut self, rhs: u16)
<<= operation. Read moreSource§impl ShlAssign<u32> for Fixed
impl ShlAssign<u32> for Fixed
Source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
<<= operation. Read moreSource§impl ShlAssign<u64> for Fixed
impl ShlAssign<u64> for Fixed
Source§fn shl_assign(&mut self, rhs: u64)
fn shl_assign(&mut self, rhs: u64)
<<= operation. Read moreSource§impl ShlAssign<u8> for Fixed
impl ShlAssign<u8> for Fixed
Source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
<<= operation. Read moreSource§impl ShlAssign<usize> for Fixed
impl ShlAssign<usize> for Fixed
Source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<= operation. Read moreSource§impl ShrAssign<&i128> for Fixed
impl ShrAssign<&i128> for Fixed
Source§fn shr_assign(&mut self, rhs: &i128)
fn shr_assign(&mut self, rhs: &i128)
>>= operation. Read moreSource§impl ShrAssign<&i16> for Fixed
impl ShrAssign<&i16> for Fixed
Source§fn shr_assign(&mut self, rhs: &i16)
fn shr_assign(&mut self, rhs: &i16)
>>= operation. Read moreSource§impl ShrAssign<&i32> for Fixed
impl ShrAssign<&i32> for Fixed
Source§fn shr_assign(&mut self, rhs: &i32)
fn shr_assign(&mut self, rhs: &i32)
>>= operation. Read moreSource§impl ShrAssign<&i64> for Fixed
impl ShrAssign<&i64> for Fixed
Source§fn shr_assign(&mut self, rhs: &i64)
fn shr_assign(&mut self, rhs: &i64)
>>= operation. Read moreSource§impl ShrAssign<&i8> for Fixed
impl ShrAssign<&i8> for Fixed
Source§fn shr_assign(&mut self, rhs: &i8)
fn shr_assign(&mut self, rhs: &i8)
>>= operation. Read moreSource§impl ShrAssign<&isize> for Fixed
impl ShrAssign<&isize> for Fixed
Source§fn shr_assign(&mut self, rhs: &isize)
fn shr_assign(&mut self, rhs: &isize)
>>= operation. Read moreSource§impl ShrAssign<&u128> for Fixed
impl ShrAssign<&u128> for Fixed
Source§fn shr_assign(&mut self, rhs: &u128)
fn shr_assign(&mut self, rhs: &u128)
>>= operation. Read moreSource§impl ShrAssign<&u16> for Fixed
impl ShrAssign<&u16> for Fixed
Source§fn shr_assign(&mut self, rhs: &u16)
fn shr_assign(&mut self, rhs: &u16)
>>= operation. Read moreSource§impl ShrAssign<&u32> for Fixed
impl ShrAssign<&u32> for Fixed
Source§fn shr_assign(&mut self, rhs: &u32)
fn shr_assign(&mut self, rhs: &u32)
>>= operation. Read moreSource§impl ShrAssign<&u64> for Fixed
impl ShrAssign<&u64> for Fixed
Source§fn shr_assign(&mut self, rhs: &u64)
fn shr_assign(&mut self, rhs: &u64)
>>= operation. Read moreSource§impl ShrAssign<&u8> for Fixed
impl ShrAssign<&u8> for Fixed
Source§fn shr_assign(&mut self, rhs: &u8)
fn shr_assign(&mut self, rhs: &u8)
>>= operation. Read moreSource§impl ShrAssign<&usize> for Fixed
impl ShrAssign<&usize> for Fixed
Source§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>= operation. Read moreSource§impl ShrAssign<i128> for Fixed
impl ShrAssign<i128> for Fixed
Source§fn shr_assign(&mut self, rhs: i128)
fn shr_assign(&mut self, rhs: i128)
>>= operation. Read moreSource§impl ShrAssign<i16> for Fixed
impl ShrAssign<i16> for Fixed
Source§fn shr_assign(&mut self, rhs: i16)
fn shr_assign(&mut self, rhs: i16)
>>= operation. Read moreSource§impl ShrAssign<i32> for Fixed
impl ShrAssign<i32> for Fixed
Source§fn shr_assign(&mut self, rhs: i32)
fn shr_assign(&mut self, rhs: i32)
>>= operation. Read moreSource§impl ShrAssign<i64> for Fixed
impl ShrAssign<i64> for Fixed
Source§fn shr_assign(&mut self, rhs: i64)
fn shr_assign(&mut self, rhs: i64)
>>= operation. Read moreSource§impl ShrAssign<i8> for Fixed
impl ShrAssign<i8> for Fixed
Source§fn shr_assign(&mut self, rhs: i8)
fn shr_assign(&mut self, rhs: i8)
>>= operation. Read moreSource§impl ShrAssign<isize> for Fixed
impl ShrAssign<isize> for Fixed
Source§fn shr_assign(&mut self, rhs: isize)
fn shr_assign(&mut self, rhs: isize)
>>= operation. Read moreSource§impl ShrAssign<u128> for Fixed
impl ShrAssign<u128> for Fixed
Source§fn shr_assign(&mut self, rhs: u128)
fn shr_assign(&mut self, rhs: u128)
>>= operation. Read moreSource§impl ShrAssign<u16> for Fixed
impl ShrAssign<u16> for Fixed
Source§fn shr_assign(&mut self, rhs: u16)
fn shr_assign(&mut self, rhs: u16)
>>= operation. Read moreSource§impl ShrAssign<u32> for Fixed
impl ShrAssign<u32> for Fixed
Source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
>>= operation. Read moreSource§impl ShrAssign<u64> for Fixed
impl ShrAssign<u64> for Fixed
Source§fn shr_assign(&mut self, rhs: u64)
fn shr_assign(&mut self, rhs: u64)
>>= operation. Read moreSource§impl ShrAssign<u8> for Fixed
impl ShrAssign<u8> for Fixed
Source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
>>= operation. Read moreSource§impl ShrAssign<usize> for Fixed
impl ShrAssign<usize> for Fixed
Source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>= operation. Read moreSource§impl SubAssign for Fixed
impl SubAssign for Fixed
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more