pub struct FixedU128 { /* private fields */ }
Expand description
Fixed precision u128
- upper 64 bits is value, lower 64 bits are the fractional portion of the
value. Each fractional portion is 1/u64::MAX
~= 5.4210e-20
or
0.000_000_000_000_000_000_054_210
, or about 54.2 zepto
, and can
accurately represent SI-prefixes milli/1e-3
, micro/1e-6
, nano/1e-9
,
pico/1e-12
, femto/1e-15
, and atto/1e-18
. This is probably overkill
for what you need. The whole portion can represent 0
-> u64::MAX
(1.84467E+19
)
Implementations§
Source§impl FixedU128
impl FixedU128
pub const fn from_parts(whole: u64, fracs: u64) -> Self
pub const fn from_raw_value(data: u128) -> Self
pub const fn trunc(&self) -> u64
pub const fn whole(&self) -> u64
pub const fn fract(&self) -> u64
pub const fn raw_value(&self) -> u128
pub fn as_f64(&self) -> f64
pub const fn is_zero(&self) -> bool
Trait Implementations§
Source§impl AddAssign<&FixedU128> for &mut FixedU128
impl AddAssign<&FixedU128> for &mut FixedU128
Source§fn add_assign(&mut self, rhs: &FixedU128)
fn add_assign(&mut self, rhs: &FixedU128)
Performs the
+=
operation. Read moreSource§impl AddAssign<&FixedU128> for FixedU128
impl AddAssign<&FixedU128> for FixedU128
Source§fn add_assign(&mut self, rhs: &FixedU128)
fn add_assign(&mut self, rhs: &FixedU128)
Performs the
+=
operation. Read moreSource§impl AddAssign<&mut FixedU128> for &mut FixedU128
impl AddAssign<&mut FixedU128> for &mut FixedU128
Source§fn add_assign(&mut self, rhs: &mut FixedU128)
fn add_assign(&mut self, rhs: &mut FixedU128)
Performs the
+=
operation. Read moreSource§impl AddAssign<&mut FixedU128> for FixedU128
impl AddAssign<&mut FixedU128> for FixedU128
Source§fn add_assign(&mut self, rhs: &mut FixedU128)
fn add_assign(&mut self, rhs: &mut FixedU128)
Performs the
+=
operation. Read moreSource§impl AddAssign<FixedU128> for &mut FixedU128
impl AddAssign<FixedU128> for &mut FixedU128
Source§fn add_assign(&mut self, rhs: FixedU128)
fn add_assign(&mut self, rhs: FixedU128)
Performs the
+=
operation. Read moreSource§impl AddAssign<f64> for &mut FixedU128
impl AddAssign<f64> for &mut FixedU128
Source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
Performs the
+=
operation. Read moreSource§impl AddAssign<f64> for FixedU128
impl AddAssign<f64> for FixedU128
Source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
Performs the
+=
operation. Read moreSource§impl AddAssign for FixedU128
impl AddAssign for FixedU128
Source§fn add_assign(&mut self, rhs: FixedU128)
fn add_assign(&mut self, rhs: FixedU128)
Performs the
+=
operation. Read moreSource§impl DivAssign for &mut FixedU128
impl DivAssign for &mut FixedU128
Source§fn div_assign(&mut self, rhs: &mut FixedU128)
fn div_assign(&mut self, rhs: &mut FixedU128)
Performs the
/=
operation. Read moreSource§impl DivAssign for FixedU128
impl DivAssign for FixedU128
Source§fn div_assign(&mut self, rhs: FixedU128)
fn div_assign(&mut self, rhs: FixedU128)
Performs the
/=
operation. Read moreSource§impl FloatExt for FixedU128
impl FloatExt for FixedU128
Source§fn exp(self) -> Self::Type
fn exp(self) -> Self::Type
Implementation of Exponential Function from NIST DTMF eq 4.2.19: <https://dlmf.nist.gov/4.2.E19>
Source§fn ln(self) -> Self::Type
fn ln(self) -> Self::Type
Implementation of Natural Logarithm using NIST DLMF eq 4.6.4: <https://dlmf.nist.gov/4.6.E4>
Source§fn powf(self, a: Self::Type) -> Self::Type
fn powf(self, a: Self::Type) -> Self::Type
Implementation of general power function using NIST DLMF eq 4.2.26: <https://dlmf.nist.gov/4.2.E26>
type Type = FixedU128
type Size = u128
fn trunc(self) -> Self::Type
fn fract(self) -> Self::Type
fn abs(self) -> Self::Type
fn round(self) -> Self::Type
fn floor(self) -> Self::Type
fn ceil(self) -> Self::Type
fn signum(self) -> Self::Type
fn powi(self, val: i32) -> Self::Type
fn sqrt(self) -> Self::Type
fn to_bits(self) -> Self::Size
fn exponent(self) -> u16
fn significand(self) -> Self::Size
Source§impl MulAssign for &mut FixedU128
impl MulAssign for &mut FixedU128
Source§fn mul_assign(&mut self, rhs: &mut FixedU128)
fn mul_assign(&mut self, rhs: &mut FixedU128)
Performs the
*=
operation. Read moreSource§impl MulAssign for FixedU128
impl MulAssign for FixedU128
Source§fn mul_assign(&mut self, rhs: FixedU128)
fn mul_assign(&mut self, rhs: FixedU128)
Performs the
*=
operation. Read moreSource§impl Ord for FixedU128
impl Ord for FixedU128
Source§impl PartialOrd<FixedU128> for u16
impl PartialOrd<FixedU128> for u16
Source§impl PartialOrd<FixedU128> for u32
impl PartialOrd<FixedU128> for u32
Source§impl PartialOrd<FixedU128> for u64
impl PartialOrd<FixedU128> for u64
Source§impl PartialOrd<FixedU128> for u8
impl PartialOrd<FixedU128> for u8
Source§impl PartialOrd<f64> for FixedU128
impl PartialOrd<f64> for FixedU128
Source§impl PartialOrd<u16> for FixedU128
impl PartialOrd<u16> for FixedU128
Source§impl PartialOrd<u32> for FixedU128
impl PartialOrd<u32> for FixedU128
Source§impl PartialOrd<u64> for FixedU128
impl PartialOrd<u64> for FixedU128
Source§impl PartialOrd<u8> for FixedU128
impl PartialOrd<u8> for FixedU128
Source§impl PartialOrd for FixedU128
impl PartialOrd for FixedU128
Source§impl SubAssign<&FixedU128> for &mut FixedU128
impl SubAssign<&FixedU128> for &mut FixedU128
Source§fn sub_assign(&mut self, rhs: &FixedU128)
fn sub_assign(&mut self, rhs: &FixedU128)
Performs the
-=
operation. Read moreSource§impl SubAssign<&FixedU128> for FixedU128
impl SubAssign<&FixedU128> for FixedU128
Source§fn sub_assign(&mut self, rhs: &FixedU128)
fn sub_assign(&mut self, rhs: &FixedU128)
Performs the
-=
operation. Read moreSource§impl SubAssign<&mut FixedU128> for &mut FixedU128
impl SubAssign<&mut FixedU128> for &mut FixedU128
Source§fn sub_assign(&mut self, rhs: &mut FixedU128)
fn sub_assign(&mut self, rhs: &mut FixedU128)
Performs the
-=
operation. Read moreSource§impl SubAssign<&mut FixedU128> for FixedU128
impl SubAssign<&mut FixedU128> for FixedU128
Source§fn sub_assign(&mut self, rhs: &mut FixedU128)
fn sub_assign(&mut self, rhs: &mut FixedU128)
Performs the
-=
operation. Read moreSource§impl SubAssign<FixedU128> for &mut FixedU128
impl SubAssign<FixedU128> for &mut FixedU128
Source§fn sub_assign(&mut self, rhs: FixedU128)
fn sub_assign(&mut self, rhs: FixedU128)
Performs the
-=
operation. Read moreSource§impl SubAssign for FixedU128
impl SubAssign for FixedU128
Source§fn sub_assign(&mut self, rhs: FixedU128)
fn sub_assign(&mut self, rhs: FixedU128)
Performs the
-=
operation. Read moreimpl Copy for FixedU128
impl Eq for FixedU128
impl StructuralPartialEq for FixedU128
Auto Trait Implementations§
impl Freeze for FixedU128
impl RefUnwindSafe for FixedU128
impl Send for FixedU128
impl Sync for FixedU128
impl Unpin for FixedU128
impl UnwindSafe for FixedU128
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