pub struct FixedUnsigned<S>where
S: FixedScale,{ /* private fields */ }
Expand description
A fixed point unsigned integer
This is a num_bigint::BigUint
with a fixed scale.
The fixed scale is determined by the generic S
which implements FixedScale
and
provides the constant FixedScale::SCALE
.
Implementations§
Source§impl<S> FixedUnsigned<S>where
S: FixedScale,
impl<S> FixedUnsigned<S>where
S: FixedScale,
Sourcepub fn int_part(&self) -> BigUint
pub fn int_part(&self) -> BigUint
Returns the integer part as BigUint
(i.e. the part before the decimal point)
pub fn frac_part(&self) -> BigUint
Sourcepub fn scale(&self) -> u64
pub fn scale(&self) -> u64
Returns the scale of the FixedUnsigned
as u64.
Note that the scale is fixed by type, so for a FixedUnsigned<S>
you can also get it as
constant by S::Scale
. This function is only for convenience.
pub fn from_bytes_be(bytes: &[u8]) -> Self
pub fn from_bytes_le(bytes: &[u8]) -> Self
pub fn to_bytes_be(&self) -> Vec<u8> ⓘ
pub fn to_bytes_le(&self) -> Vec<u8> ⓘ
Sourcepub fn to_radix_string(&self, radix: u8, uppercase: bool) -> String
pub fn to_radix_string(&self, radix: u8, uppercase: bool) -> String
Converts the FixedUnsigned
to a string representation in base radix
.
§Panics
This function will panic if the radix is 0 or greater than 36.
Sourcepub fn from_radix_string(string: &str, radix: u8) -> Result<Self, ParseError>
pub fn from_radix_string(string: &str, radix: u8) -> Result<Self, ParseError>
Converts a string representation to a FixedUnsigned
with base radix
.
NOTE: This function always rounds down.
§Panics
This function will panic if the radix is 0 or greater than 36.
Sourcepub fn into_biguint(self) -> BigUint
pub fn into_biguint(self) -> BigUint
Converts to a BigUint losing the decimal places
NOTE: This is not implemented as a Into
/From
trait to make the loss of precision implicit
pub fn into_biguint_without_scale(self) -> BigUint
pub fn bits(&self) -> usize
pub fn bytes(&self) -> usize
Sourcepub fn into_scale<T: FixedScale, R: RoundingMode>(self) -> FixedUnsigned<T>
pub fn into_scale<T: FixedScale, R: RoundingMode>(self) -> FixedUnsigned<T>
Convert from scale S
to scale T
.
Trait Implementations§
Source§impl<'a, 'b, S> Add<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
impl<'a, 'b, S> Add<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
+
operator.Source§fn add(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
fn add(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
+
operation. Read moreSource§impl<S> Add for FixedUnsigned<S>where
S: FixedScale,
impl<S> Add for FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
+
operator.Source§impl<S> AddAssign for FixedUnsigned<S>where
S: FixedScale,
impl<S> AddAssign for FixedUnsigned<S>where
S: FixedScale,
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moreSource§impl<S> Clone for FixedUnsigned<S>where
S: FixedScale + Clone,
impl<S> Clone for FixedUnsigned<S>where
S: FixedScale + Clone,
Source§fn clone(&self) -> FixedUnsigned<S>
fn clone(&self) -> FixedUnsigned<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<S> Debug for FixedUnsigned<S>where
S: FixedScale,
impl<S> Debug for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S> Default for FixedUnsigned<S>where
S: FixedScale,
impl<S> Default for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S> Display for FixedUnsigned<S>where
S: FixedScale,
impl<S> Display for FixedUnsigned<S>where
S: FixedScale,
Source§impl<'a, 'b, S> Div<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
impl<'a, 'b, S> Div<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
/
operator.Source§fn div(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
fn div(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
/
operation. Read moreSource§impl<S> Div for FixedUnsigned<S>where
S: FixedScale,
impl<S> Div for FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
/
operator.Source§impl<S> DivAssign for FixedUnsigned<S>where
S: FixedScale,
impl<S> DivAssign for FixedUnsigned<S>where
S: FixedScale,
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moreSource§impl<S> From<BigUint> for FixedUnsigned<S>where
S: FixedScale,
impl<S> From<BigUint> for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S: FixedScale> From<f64> for FixedUnsigned<S>
Converts a f64
to a FixedUnsigned
impl<S: FixedScale> From<f64> for FixedUnsigned<S>
Converts a f64
to a FixedUnsigned
Source§impl<S: FixedScale> From<u16> for FixedUnsigned<S>
impl<S: FixedScale> From<u16> for FixedUnsigned<S>
Source§impl<S: FixedScale> From<u32> for FixedUnsigned<S>
impl<S: FixedScale> From<u32> for FixedUnsigned<S>
Source§impl<S: FixedScale> From<u64> for FixedUnsigned<S>
impl<S: FixedScale> From<u64> for FixedUnsigned<S>
Source§impl<S: FixedScale> From<u8> for FixedUnsigned<S>
impl<S: FixedScale> From<u8> for FixedUnsigned<S>
Source§impl<S> FromStr for FixedUnsigned<S>where
S: FixedScale,
impl<S> FromStr for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S> Hash for FixedUnsigned<S>where
S: FixedScale,
impl<S> Hash for FixedUnsigned<S>where
S: FixedScale,
Source§impl<'a, 'b, S> Mul<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
impl<'a, 'b, S> Mul<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
*
operator.Source§fn mul(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
fn mul(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
*
operation. Read moreSource§impl<S> Mul for FixedUnsigned<S>where
S: FixedScale,
impl<S> Mul for FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
*
operator.Source§impl<S> MulAssign for FixedUnsigned<S>where
S: FixedScale,
impl<S> MulAssign for FixedUnsigned<S>where
S: FixedScale,
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moreSource§impl<S> One for FixedUnsigned<S>where
S: FixedScale,
impl<S> One for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S> Ord for FixedUnsigned<S>where
S: FixedScale,
impl<S> Ord for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S> PartialEq for FixedUnsigned<S>where
S: FixedScale,
impl<S> PartialEq for FixedUnsigned<S>where
S: FixedScale,
Source§impl<S> PartialOrd for FixedUnsigned<S>where
S: FixedScale,
impl<S> PartialOrd for FixedUnsigned<S>where
S: FixedScale,
Source§impl<'a, 'b, S> Sub<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
impl<'a, 'b, S> Sub<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
-
operator.Source§fn sub(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
fn sub(self, rhs: &'b FixedUnsigned<S>) -> FixedUnsigned<S>
-
operation. Read moreSource§impl<S> Sub for FixedUnsigned<S>where
S: FixedScale,
impl<S> Sub for FixedUnsigned<S>where
S: FixedScale,
Source§type Output = FixedUnsigned<S>
type Output = FixedUnsigned<S>
-
operator.Source§impl<S> SubAssign for FixedUnsigned<S>where
S: FixedScale,
impl<S> SubAssign for FixedUnsigned<S>where
S: FixedScale,
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more