Skip to main content

Number

Struct Number 

Source
pub struct Number(/* private fields */);
Expand description

Scheme numeric type.

Implementations§

Source§

impl Number

Source

pub fn as_simple(&self) -> Option<&SimpleNumber>

Source

pub fn as_complex(&self) -> Option<&ComplexNumber>

Source

pub fn is_zero(&self) -> bool

Source

pub fn is_integer(&self) -> bool

Source

pub fn is_rational(&self) -> bool

Source

pub fn is_real(&self) -> bool

Source

pub fn is_integer_valued(&self) -> bool

Source

pub fn is_rational_valued(&self) -> bool

Source

pub fn is_real_valued(&self) -> bool

Source

pub fn is_complex(&self) -> bool

All numbers are complex!

Source

pub fn is_exact(&self) -> bool

Source

pub fn is_inexact(&self) -> bool

Source

pub fn inexact(self) -> Number

Source

pub fn exact(self) -> Number

Source

pub fn eqv(&self, rhs: &Self) -> bool

Source

pub fn pow(&self, rhs: &Number) -> Number

Source

pub fn exp(&self) -> Self

Source

pub fn ln(&self) -> Self

Source

pub fn sqrt(&self) -> Self

Source

pub fn sin(&self) -> Self

Source

pub fn cos(&self) -> Self

Source

pub fn tan(&self) -> Self

Source

pub fn asin(&self) -> Self

Source

pub fn acos(&self) -> Self

Source

pub fn atan(&self) -> Self

Trait Implementations§

Source§

impl Add for &Number

Source§

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 Add for Number

Source§

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 Clone for Number

Source§

fn clone(&self) -> Number

Returns a duplicate 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 Display for Number

Source§

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

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

impl Div for &Number

Source§

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 Div for Number

Source§

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 From<&Number> for Option<ComplexNumber>

Source§

fn from(value: &Number) -> Self

Converts to this type from the input type.
Source§

impl From<&Number> for Option<Integer>

Source§

fn from(num: &Number) -> Option<Integer>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<SimpleNumber>

Source§

fn from(value: &Number) -> Self

Converts to this type from the input type.
Source§

impl From<&Number> for Option<f64>

Source§

fn from(num: &Number) -> Option<f64>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<i128>

Source§

fn from(num: &Number) -> Option<i128>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<i16>

Source§

fn from(num: &Number) -> Option<i16>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<i32>

Source§

fn from(num: &Number) -> Option<i32>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<i64>

Source§

fn from(num: &Number) -> Option<i64>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<i8>

Source§

fn from(num: &Number) -> Option<i8>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<isize>

Source§

fn from(num: &Number) -> Option<isize>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<u128>

Source§

fn from(num: &Number) -> Option<u128>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<u16>

Source§

fn from(num: &Number) -> Option<u16>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<u32>

Source§

fn from(num: &Number) -> Option<u32>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<u64>

Source§

fn from(num: &Number) -> Option<u64>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<u8>

Source§

fn from(num: &Number) -> Option<u8>

Converts to this type from the input type.
Source§

impl From<&Number> for Option<usize>

Source§

fn from(num: &Number) -> Option<usize>

Converts to this type from the input type.
Source§

impl From<ComplexNumber> for Number

Source§

fn from(complex: ComplexNumber) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Option<ComplexNumber>

Source§

fn from(value: Number) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Option<Integer>

Source§

fn from(num: Number) -> Option<Integer>

Converts to this type from the input type.
Source§

impl From<Number> for Option<SimpleNumber>

Source§

fn from(value: Number) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Option<f64>

Source§

fn from(num: Number) -> Option<f64>

Converts to this type from the input type.
Source§

impl From<Number> for Option<i128>

Source§

fn from(num: Number) -> Option<i128>

Converts to this type from the input type.
Source§

impl From<Number> for Option<i16>

Source§

fn from(num: Number) -> Option<i16>

Converts to this type from the input type.
Source§

impl From<Number> for Option<i32>

Source§

fn from(num: Number) -> Option<i32>

Converts to this type from the input type.
Source§

impl From<Number> for Option<i64>

Source§

fn from(num: Number) -> Option<i64>

Converts to this type from the input type.
Source§

impl From<Number> for Option<i8>

Source§

fn from(num: Number) -> Option<i8>

Converts to this type from the input type.
Source§

impl From<Number> for Option<isize>

Source§

fn from(num: Number) -> Option<isize>

Converts to this type from the input type.
Source§

impl From<Number> for Option<u128>

Source§

fn from(num: Number) -> Option<u128>

Converts to this type from the input type.
Source§

impl From<Number> for Option<u16>

Source§

fn from(num: Number) -> Option<u16>

Converts to this type from the input type.
Source§

impl From<Number> for Option<u32>

Source§

fn from(num: Number) -> Option<u32>

Converts to this type from the input type.
Source§

impl From<Number> for Option<u64>

Source§

fn from(num: Number) -> Option<u64>

Converts to this type from the input type.
Source§

impl From<Number> for Option<u8>

Source§

fn from(num: Number) -> Option<u8>

Converts to this type from the input type.
Source§

impl From<Number> for Option<usize>

Source§

fn from(num: Number) -> Option<usize>

Converts to this type from the input type.
Source§

impl From<Number> for UnpackedValue

Source§

fn from(v: Number) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Value

Source§

fn from(v: Number) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for Number
where SimpleNumber: From<T>,

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl Hash for Number

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul for &Number

Source§

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 Mul for Number

Source§

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 Neg for &Number

Source§

type Output = Number

The resulting type after applying the - operator.
Source§

fn neg(self) -> Number

Performs the unary - operation. Read more
Source§

impl Neg for Number

Source§

type Output = Number

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Number

Source§

fn eq(&self, rhs: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Number

Source§

fn partial_cmp(&self, rhs: &Self) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub for &Number

Source§

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 Sub for Number

Source§

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 Trace for Number

Source§

unsafe fn visit_children(&self, visitor: &mut dyn FnMut(OpaqueGcPtr))

Safety Read more
Source§

unsafe fn finalize(&mut self)

Safety Read more
Source§

impl TryFrom<&Number> for ComplexNumber

Source§

type Error = Exception

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

fn try_from(value: &Number) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for Integer

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<Integer, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for SimpleNumber

Source§

type Error = Exception

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

fn try_from(value: &Number) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for f64

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<f64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for i128

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<i128, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for i16

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<i16, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for i32

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<i32, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for i64

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<i64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for i8

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<i8, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for isize

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<isize, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for u128

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<u128, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for u16

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<u16, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for u32

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<u32, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for u64

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<u64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for u8

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<u8, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Number> for usize

Source§

type Error = Exception

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

fn try_from(num: &Number) -> Result<usize, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for Number

Source§

type Error = Exception

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

fn try_from(v: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for ComplexNumber

Source§

type Error = Exception

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

fn try_from(value: Number) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for Integer

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<Integer, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for Number

Source§

type Error = ParseNumberError

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

fn try_from(value: Number) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for SimpleNumber

Source§

type Error = Exception

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

fn try_from(value: Number) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for f64

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<f64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for i128

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<i128, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for i16

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<i16, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for i32

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<i32, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for i64

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<i64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for i8

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<i8, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for isize

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<isize, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for u128

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<u128, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for u16

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<u16, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for u32

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<u32, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for u64

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<u64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for u8

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<u8, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Number> for usize

Source§

type Error = Exception

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

fn try_from(num: Number) -> Result<usize, Self::Error>

Performs the conversion.
Source§

impl TryFrom<UnpackedValue> for Number

Source§

type Error = Exception

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

fn try_from(v: UnpackedValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Number

Source§

type Error = Exception

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Number

§

impl RefUnwindSafe for Number

§

impl Send for Number

§

impl Sync for Number

§

impl Unpin for Number

§

impl UnwindSafe for Number

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U