Enum reform::number::Number [−][src]
pub enum Number { SmallInt(isize), BigInt(Integer), SmallRat(isize, isize), BigRat(Box<Rational>), }
A number is either a small number consisting of machine sized integers or a big number, using GMP.
The mathematical operations on a number automatically upgrade and downgrade to bigint/smallint etc. TODO: hash should take into account that some bigints can be equal to smallint?
Variants
SmallInt(isize)
BigInt(Integer)
SmallRat(isize, isize)
BigRat(Box<Rational>)
Methods
impl Number
[src]
impl Number
pub fn normalize_inplace(&mut self) -> bool
[src]
pub fn normalize_inplace(&mut self) -> bool
pub fn normalized(self) -> Self
[src]
pub fn normalized(self) -> Self
pub fn factorial(self) -> Number
[src]
pub fn factorial(self) -> Number
Returns the factorial of the number.
pub fn abs(&self) -> Number
[src]
pub fn abs(&self) -> Number
impl Number
[src]
impl Number
pub fn serialize(&self, buffer: &mut Write) -> usize
[src]
pub fn serialize(&self, buffer: &mut Write) -> usize
pub fn deserialize(buffer: &mut Read) -> Result<Number, Error>
[src]
pub fn deserialize(buffer: &mut Read) -> Result<Number, Error>
pub fn compare_serialized(
b1: &mut Cursor<&Vec<u8>>,
b2: &mut Cursor<&Vec<u8>>
) -> Ordering
[src]
pub fn compare_serialized(
b1: &mut Cursor<&Vec<u8>>,
b2: &mut Cursor<&Vec<u8>>
) -> Ordering
Trait Implementations
impl Debug for Number
[src]
impl Debug for Number
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Number
[src]
impl Clone for Number
fn clone(&self) -> Number
[src]
fn clone(&self) -> Number
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Hash for Number
[src]
impl Hash for Number
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Number
[src]
impl PartialEq for Number
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
Compare numbers. Big integers can also match small integers.
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for Number
[src]
impl Eq for Number
impl Display for Number
[src]
impl Display for Number
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Zero for Number
[src]
impl Zero for Number
fn zero() -> Number
[src]
fn zero() -> Number
Returns the additive identity element of Self
, 0
. Read more
fn is_zero(&self) -> bool
[src]
fn is_zero(&self) -> bool
Returns true
if self
is equal to the additive identity.
impl GCD for Number
[src]
impl GCD for Number
impl One for Number
[src]
impl One for Number
fn one() -> Number
[src]
fn one() -> Number
Returns the multiplicative identity element of Self
, 1
. Read more
fn is_one(&self) -> bool
[src]
fn is_one(&self) -> bool
Returns true
if self
is equal to the multiplicative identity. Read more
impl Neg for Number
[src]
impl Neg for Number
type Output = Number
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
fn neg(self) -> Self::Output
Performs the unary -
operation.
impl Inv for Number
[src]
impl Inv for Number
type Output = Number
The result after applying the operator.
fn inv(self) -> Self::Output
[src]
fn inv(self) -> Self::Output
Returns the multiplicative inverse of self
. Read more
impl PartialOrd for Number
[src]
impl PartialOrd for Number
fn partial_cmp(&self, rhs: &Number) -> Option<Ordering>
[src]
fn partial_cmp(&self, rhs: &Number) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
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
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
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
impl Ord for Number
[src]
impl Ord for Number
fn cmp(&self, other: &Number) -> Ordering
[src]
fn cmp(&self, other: &Number) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Add for Number
[src]
impl Add for Number
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Number) -> Number
[src]
fn add(self, rhs: Number) -> Number
Performs the +
operation.
impl Sub for Number
[src]
impl Sub for Number
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Number) -> Number
[src]
fn sub(self, rhs: Number) -> Number
Performs the -
operation.
impl Mul for Number
[src]
impl Mul for Number
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: Number) -> Number
[src]
fn mul(self, rhs: Number) -> Number
Performs the *
operation.
impl Div for Number
[src]
impl Div for Number
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Number) -> Number
[src]
fn div(self, rhs: Number) -> Number
Performs the /
operation.
impl Rem for Number
[src]
impl Rem for Number
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, rhs: Number) -> Number
[src]
fn rem(self, rhs: Number) -> Number
Performs the %
operation.
impl Pow<u32> for Number
[src]
impl Pow<u32> for Number
type Output = Self
The result after applying the operator.
fn pow(self, rhs: u32) -> Number
[src]
fn pow(self, rhs: u32) -> Number
Returns self
to the power rhs
. Read more
impl MulAssign for Number
[src]
impl MulAssign for Number
fn mul_assign(&mut self, rhs: Number)
[src]
fn mul_assign(&mut self, rhs: Number)
Performs the *=
operation.
impl AddAssign for Number
[src]
impl AddAssign for Number
fn add_assign(&mut self, rhs: Number)
[src]
fn add_assign(&mut self, rhs: Number)
Performs the +=
operation.
impl Mul<Number> for Polynomial
[src]
impl Mul<Number> for Polynomial