pub struct Fp64<F = _24> { /* private fields */ }Expand description
A 64 bits fixed point number. The size of the fractional is defined by the type parameter F.
Implementations§
Source§impl<F: FractionalBits> Fp64<F>
impl<F: FractionalBits> Fp64<F>
Sourcepub fn raw(self) -> i64
pub fn raw(self) -> i64
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: i64) -> 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) -> Fp64<NewF>
pub fn to_fixed<NewF: FractionalBits>(self) -> Fp64<NewF>
Returns the same number with a different fractional precision.
Source§impl<F: FractionalBits> Fp64<F>
impl<F: FractionalBits> Fp64<F>
pub fn one() -> Self
pub fn from_i64(val: i64) -> Self
Sourcepub fn truncate_to_i64(self) -> i64
pub fn truncate_to_i64(self) -> i64
Convert to an i64, 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.
Sourcepub fn to_fp32<NewF: FractionalBits>(self) -> Fp32<NewF>
pub fn to_fp32<NewF: FractionalBits>(self) -> Fp32<NewF>
Casts into a 32 bits fixed point number.
Trait Implementations§
Source§impl<F: FractionalBits> Add for Fp64<F>
impl<F: FractionalBits> Add for Fp64<F>
Source§impl<F: FractionalBits> AddAssign for Fp64<F>
impl<F: FractionalBits> AddAssign for Fp64<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 Fp64<F>
impl<F: FractionalBits> Debug for Fp64<F>
Source§impl<F: FractionalBits> Display for Fp64<F>
impl<F: FractionalBits> Display for Fp64<F>
Source§impl<F: FractionalBits> Div for Fp64<F>
impl<F: FractionalBits> Div for Fp64<F>
Source§impl<F: FractionalBits> Mul for Fp64<F>
impl<F: FractionalBits> Mul for Fp64<F>
Source§impl<F: FractionalBits> Neg for Fp64<F>
impl<F: FractionalBits> Neg for Fp64<F>
Source§impl<F: FractionalBits> Ord for Fp64<F>
impl<F: FractionalBits> Ord for Fp64<F>
Source§impl<F: FractionalBits> PartialOrd for Fp64<F>
impl<F: FractionalBits> PartialOrd for Fp64<F>
Source§impl<F: FractionalBits> Sub for Fp64<F>
impl<F: FractionalBits> Sub for Fp64<F>
Source§impl<F: FractionalBits> SubAssign for Fp64<F>
impl<F: FractionalBits> SubAssign for Fp64<F>
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreimpl<F> Copy for Fp64<F>
impl<F> Eq for Fp64<F>
Auto Trait Implementations§
impl<F> Freeze for Fp64<F>
impl<F> RefUnwindSafe for Fp64<F>where
F: RefUnwindSafe,
impl<F> Send for Fp64<F>where
F: Send,
impl<F> Sync for Fp64<F>where
F: Sync,
impl<F> Unpin for Fp64<F>where
F: Unpin,
impl<F> UnwindSafe for Fp64<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