#[repr(transparent)]pub struct Q15(pub i16);Expand description
Strongly-typed Q1.15 fixed-point number stored in an i16.
Range is [-1.0, 0.999969482421875].
Provides operator overloading (+, -, *, /) with saturating fixed-point arithmetic.
Tuple Fields§
§0: i16Implementations§
Source§impl Q15
impl Q15
Sourcepub fn from_f32(v: f32) -> Self
pub fn from_f32(v: f32) -> Self
Convert from f32 with rounding and saturation to [-1.0, 0.999969].
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Saturating addition.
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Saturating subtraction.
Sourcepub fn saturating_mul(self, rhs: Self) -> Self
pub fn saturating_mul(self, rhs: Self) -> Self
Saturating Q15 multiplication.
Sourcepub fn saturating_div(self, rhs: Self) -> Self
pub fn saturating_div(self, rhs: Self) -> Self
Saturating Q15 division with division-by-zero protection.
Trait Implementations§
Source§impl AddAssign for Q15
impl AddAssign for Q15
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl Copy for Q15
Source§impl DivAssign for Q15
impl DivAssign for Q15
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moreimpl Eq for Q15
Source§impl MulAssign for Q15
impl MulAssign for Q15
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl Ord for Q15
impl Ord for Q15
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Q15
impl PartialOrd for Q15
impl StructuralPartialEq for Q15
Auto Trait Implementations§
impl Freeze for Q15
impl RefUnwindSafe for Q15
impl Send for Q15
impl Sync for Q15
impl Unpin for Q15
impl UnsafeUnpin for Q15
impl UnwindSafe for Q15
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
Mutably borrows from an owned value. Read more