#[repr(C)]pub struct Signed1616FixedPoint(_);
Expand description
A Q-format Q16.16
signed fixed point number, viz:-
- Integer component is signed and 16 bits (
i16
). - Fraction component is 16 bits.
See upstream library https://github.com/PetteriAimonen/libfixmath
for example code to implement trigonometric functions.
Implementations
sourceimpl Signed1616FixedPoint
impl Signed1616FixedPoint
sourcepub const InclusiveMinimum: Self = Self::new(0x8000u16 as i16, Self::ZeroFraction)
pub const InclusiveMinimum: Self = Self::new(0x8000u16 as i16, Self::ZeroFraction)
Inclusive minimum.
sourcepub const InclusiveMaximum: Self = Self::new(Self::LargestInteger, 0xFFFF)
pub const InclusiveMaximum: Self = Self::new(Self::LargestInteger, 0xFFFF)
Inclusive maximum.
sourcepub const fn abs(self) -> Self
pub const fn abs(self) -> Self
Computes the absolute value of self.
The absolute value of Self::InclusiveMinimum
cannot be represented without a sign, and attempting to calculate it will cause an overflow.
This means that code in debug mode will trigger a panic on this case and optimized code will return Self::InclusiveMinimum
without a panic.
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true if self is positive and false if the number is zero or negative.
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true if self is negative and false if the number is zero or positive.
sourcepub const fn signum(self) -> i16
pub const fn signum(self) -> i16
Returns a number representing sign of self.
0
if the number is zero.1
if the number is positive.-1
if the number is negative.
sourcepub fn saturating_add(self, rhs: Self) -> Self
pub fn saturating_add(self, rhs: Self) -> Self
Saturating addition.
sourcepub fn saturating_sub(self, rhs: Self) -> Self
pub 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 multiplication.
sourcepub fn saturating_div(self, rhs: Self) -> Self
pub fn saturating_div(self, rhs: Self) -> Self
Saturating division.
sourcepub fn checked_add(self, rhs: Self) -> Option<Self>
pub fn checked_add(self, rhs: Self) -> Option<Self>
Checked addition.
sourcepub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
Checked subtraction.
sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Checked multiplication.
Takes advantage of 64-bit CPUs.
Performs a 32 × 32 -> 64 bit multiplication. The middle 32 bits are the result, the bottom 16 bits are used for rounding, and the upper 16 bits are used for overflow detection.
sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Checked division.
Takes advantage of 32-bit CPUs. Does not take advantage of 64-bit CPUs.
sourcepub fn saturating_mul_by_scalar(self, scalar: i16) -> Self
pub fn saturating_mul_by_scalar(self, scalar: i16) -> Self
Saturating multiply by a scalar.
sourcepub fn checked_mul_by_scalar(self, scalar: i16) -> Option<Self>
pub fn checked_mul_by_scalar(self, scalar: i16) -> Option<Self>
Checked multiply by a scalar.
sourcepub fn checked_div_by_scalar(self, scalar: i16) -> Option<Self>
pub fn checked_div_by_scalar(self, scalar: i16) -> Option<Self>
Checked divide by a scalar.
Trait Implementations
sourceimpl AddAssign<Signed1616FixedPoint> for Signed1616FixedPoint
impl AddAssign<Signed1616FixedPoint> for Signed1616FixedPoint
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the +=
operation. Read more
sourceimpl Clone for Signed1616FixedPoint
impl Clone for Signed1616FixedPoint
sourcefn clone(&self) -> Signed1616FixedPoint
fn clone(&self) -> Signed1616FixedPoint
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Signed1616FixedPoint
impl Debug for Signed1616FixedPoint
sourceimpl Default for Signed1616FixedPoint
impl Default for Signed1616FixedPoint
sourcefn default() -> Signed1616FixedPoint
fn default() -> Signed1616FixedPoint
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for Signed1616FixedPoint
impl<'de> Deserialize<'de> for Signed1616FixedPoint
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl DivAssign<Signed1616FixedPoint> for Signed1616FixedPoint
impl DivAssign<Signed1616FixedPoint> for Signed1616FixedPoint
sourcefn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the /=
operation. Read more
sourceimpl From<([u8; 2], [u8; 2])> for Signed1616FixedPoint
impl From<([u8; 2], [u8; 2])> for Signed1616FixedPoint
sourcefn from(value: (BigEndianI16, BigEndianU16)) -> Self
fn from(value: (BigEndianI16, BigEndianU16)) -> Self
Converts to this type from the input type.
sourceimpl From<i32> for Signed1616FixedPoint
impl From<i32> for Signed1616FixedPoint
sourceimpl From<u32> for Signed1616FixedPoint
impl From<u32> for Signed1616FixedPoint
sourceimpl Hash for Signed1616FixedPoint
impl Hash for Signed1616FixedPoint
sourceimpl Into<([u8; 2], [u8; 2])> for Signed1616FixedPoint
impl Into<([u8; 2], [u8; 2])> for Signed1616FixedPoint
sourcefn into(self) -> (BigEndianI16, BigEndianU16)
fn into(self) -> (BigEndianI16, BigEndianU16)
Converts this type into the (usually inferred) input type.
sourceimpl Into<i32> for Signed1616FixedPoint
impl Into<i32> for Signed1616FixedPoint
sourceimpl Into<u32> for Signed1616FixedPoint
impl Into<u32> for Signed1616FixedPoint
sourceimpl MulAssign<Signed1616FixedPoint> for Signed1616FixedPoint
impl MulAssign<Signed1616FixedPoint> for Signed1616FixedPoint
sourcefn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the *=
operation. Read more
sourceimpl Neg for Signed1616FixedPoint
impl Neg for Signed1616FixedPoint
type Output = Signed1616FixedPoint
type Output = Signed1616FixedPoint
The resulting type after applying the -
operator.
sourceimpl Ord for Signed1616FixedPoint
impl Ord for Signed1616FixedPoint
sourceimpl PartialOrd<Signed1616FixedPoint> for Signed1616FixedPoint
impl PartialOrd<Signed1616FixedPoint> for Signed1616FixedPoint
sourcefn partial_cmp(&self, rhs: &Self) -> Option<Ordering>
fn partial_cmp(&self, rhs: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl RemAssign<Signed1616FixedPoint> for Signed1616FixedPoint
impl RemAssign<Signed1616FixedPoint> for Signed1616FixedPoint
sourcefn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the %=
operation. Read more
sourceimpl Serialize for Signed1616FixedPoint
impl Serialize for Signed1616FixedPoint
sourceimpl SubAssign<Signed1616FixedPoint> for Signed1616FixedPoint
impl SubAssign<Signed1616FixedPoint> for Signed1616FixedPoint
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -=
operation. Read more
sourceimpl TryFrom<Signed1616FixedPoint> for Unsigned1616FixedPoint
impl TryFrom<Signed1616FixedPoint> for Unsigned1616FixedPoint
type Error = ParseNumberError
type Error = ParseNumberError
The type returned in the event of a conversion error.
sourcefn try_from(value: Signed1616FixedPoint) -> Result<Self, Self::Error>
fn try_from(value: Signed1616FixedPoint) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl TryFrom<Unsigned1616FixedPoint> for Signed1616FixedPoint
impl TryFrom<Unsigned1616FixedPoint> for Signed1616FixedPoint
type Error = ParseNumberError
type Error = ParseNumberError
The type returned in the event of a conversion error.
sourcefn try_from(value: Unsigned1616FixedPoint) -> Result<Self, Self::Error>
fn try_from(value: Unsigned1616FixedPoint) -> Result<Self, Self::Error>
Performs the conversion.
impl Copy for Signed1616FixedPoint
impl Eq for Signed1616FixedPoint
Auto Trait Implementations
impl RefUnwindSafe for Signed1616FixedPoint
impl Send for Signed1616FixedPoint
impl Sync for Signed1616FixedPoint
impl Unpin for Signed1616FixedPoint
impl UnwindSafe for Signed1616FixedPoint
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more