pub struct Fp32<F = _16> { /* private fields */ }Expand description
A 32 fixed point number. The size of the fractional is defined by the type parameter F.
Implementations§
Source§impl<F: FractionalBits> Fp32<F>
impl<F: FractionalBits> Fp32<F>
Sourcepub fn raw(self) -> i32
pub fn raw(self) -> i32
Returns the internal representation.
This internal represenataion can be used for computations to avoid bit-shifting between each operation. The number of divisions should be equal to the number of multiplications performed in order to balance out the bit shifts that were skipped.
pub fn from_raw(bits: i32) -> Self
pub fn zero() -> Self
pub fn is_zero(self) -> bool
Sourcepub fn min_max(self, other: Self) -> (Self, Self)
pub fn min_max(self, other: Self) -> (Self, Self)
Returns the lowest and highest of the two values in order.
Sourcepub fn to_fixed<NewF: FractionalBits>(self) -> Fp32<NewF>
pub fn to_fixed<NewF: FractionalBits>(self) -> Fp32<NewF>
Returns the same number with a different fractional precision.
Source§impl<F: FractionalBits> Fp32<F>
impl<F: FractionalBits> Fp32<F>
pub fn one() -> Self
pub fn from_i32(val: i32) -> Self
Sourcepub fn truncate_to_i32(self) -> i32
pub fn truncate_to_i32(self) -> i32
Convert to an i32, truncating the fractional part
Sourcepub fn mul_div(self, m: Self, d: Self) -> Self
pub fn mul_div(self, m: Self, d: Self) -> Self
Computes the self * m / d in one go, avoid the precision loss from shifting bits back and forth.
pub fn min_val() -> Self
pub fn max_val() -> Self
Sourcepub fn to_fp64<NewF: FractionalBits>(self) -> Fp64<NewF>
pub fn to_fp64<NewF: FractionalBits>(self) -> Fp64<NewF>
Casts into a 64 bits fixed point number.
Trait Implementations§
Source§impl<F: FractionalBits> Add for Fp32<F>
impl<F: FractionalBits> Add for Fp32<F>
Source§impl<F: FractionalBits> AddAssign for Fp32<F>
impl<F: FractionalBits> AddAssign for Fp32<F>
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl<F: FractionalBits> Debug for Fp32<F>
impl<F: FractionalBits> Debug for Fp32<F>
Source§impl<F: FractionalBits> Display for Fp32<F>
impl<F: FractionalBits> Display for Fp32<F>
Source§impl<F: FractionalBits> Div for Fp32<F>
impl<F: FractionalBits> Div for Fp32<F>
Source§impl<F: FractionalBits> Mul for Fp32<F>
impl<F: FractionalBits> Mul for Fp32<F>
Source§impl<F: FractionalBits> Neg for Fp32<F>
impl<F: FractionalBits> Neg for Fp32<F>
Source§impl<F: FractionalBits> Ord for Fp32<F>
impl<F: FractionalBits> Ord for Fp32<F>
Source§impl<F: FractionalBits> PartialOrd for Fp32<F>
impl<F: FractionalBits> PartialOrd for Fp32<F>
Source§impl<F: FractionalBits> Sub for Fp32<F>
impl<F: FractionalBits> Sub for Fp32<F>
Source§impl<F: FractionalBits> SubAssign for Fp32<F>
impl<F: FractionalBits> SubAssign for Fp32<F>
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreimpl<F> Copy for Fp32<F>
impl<F> Eq for Fp32<F>
Auto Trait Implementations§
impl<F> Freeze for Fp32<F>
impl<F> RefUnwindSafe for Fp32<F>where
F: RefUnwindSafe,
impl<F> Send for Fp32<F>where
F: Send,
impl<F> Sync for Fp32<F>where
F: Sync,
impl<F> Unpin for Fp32<F>where
F: Unpin,
impl<F> UnwindSafe for Fp32<F>where
F: UnwindSafe,
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