Struct psy_math::Number

source ·
pub struct Number(_);
Expand description

A large unsigned integer

Implementations§

source§

impl Number

source

pub const ONE: Number = _

source

pub const ZERO: Number = _

source

pub fn as_u64(&self, exponent: impl Into<i32>) -> u64

Convert this number to fit in a u64

The precision of the number in the u64 is based on the exponent provided.

source

pub fn as_u64_ceil(&self, exponent: impl Into<i32>) -> u64

Ceiling value of number, fit in a u64

The precision of the number in the u64 is based on the exponent provided.

The result is rounded up to the nearest one, based on the target precision.

source

pub fn as_u64_rounded(&self, exponent: impl Into<i32>) -> u64

Convert this number to fit in a u64

The precision of the number in the u64 is based on the exponent provided.

The result is rounded to the nearest one, based on the target precision.

source

pub fn from_decimal(value: impl Into<U192>, exponent: impl Into<i32>) -> Self

Convert another integer into a Number.

source

pub fn from_bps(basis_points: u16) -> Number

Convert from basis points into a Number

source

pub fn pow(&self, exp: impl Into<Number>) -> Number

source

pub fn saturating_add(&self, n: Number) -> Number

source

pub fn saturating_sub(&self, n: Number) -> Number

source

pub fn saturating_mul(&self, n: Number) -> Number

source

pub fn ten_pow(exponent: u32) -> U192

source

pub fn into_bits(self) -> [u8; 24]

Get the underlying representation in bits

source

pub fn from_bits(bits: [u8; 24]) -> Self

Read a number from a raw 196-bit representation, which was previously returned by a call to into_bits.

Trait Implementations§

source§

impl Add<Number> for Number

§

type Output = Number

The resulting type after applying the + operator.
source§

fn add(self, rhs: Number) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<Number> for Number

source§

fn add_assign(&mut self, rhs: Number)

Performs the += operation. Read more
source§

impl Clone for Number

source§

fn clone(&self) -> Number

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Number

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Number

source§

fn default() -> Number

Returns the “default value” for a type. Read more
source§

impl Display for Number

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Div<Number> for Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, rhs: Number) -> Self::Output

Performs the / operation. Read more
source§

impl<T: Into<U192>> Div<T> for Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
source§

impl From<Number> for [u8; 24]

source§

fn from(n: Number) -> Self

Converts to this type from the input type.
source§

impl<T: Into<U192>> From<T> for Number

source§

fn from(n: T) -> Number

Converts to this type from the input type.
source§

impl Mul<Number> for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Number) -> Self::Output

Performs the * operation. Read more
source§

impl<T: Into<U192>> Mul<T> for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
source§

impl MulAssign<Number> for Number

source§

fn mul_assign(&mut self, rhs: Number)

Performs the *= operation. Read more
source§

impl Ord for Number

source§

fn cmp(&self, other: &Number) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Number> for Number

source§

fn eq(&self, other: &Number) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Number> for Number

source§

fn partial_cmp(&self, other: &Number) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Number> for Number

§

type Output = Number

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Number) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign<Number> for Number

source§

fn sub_assign(&mut self, rhs: Number)

Performs the -= operation. Read more
source§

impl Sum<Number> for Number

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Zeroable for Number

source§

fn zeroed() -> Self

source§

impl Copy for Number

source§

impl Eq for Number

source§

impl Pod for Number

source§

impl StructuralEq for Number

source§

impl StructuralPartialEq for Number

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> AnyBitPattern for Twhere T: Pod,

source§

impl<T> NoUninit for Twhere T: Pod,