Struct Context

Source
pub struct Context { /* private fields */ }
Expand description

Context contains parameters, like rounding mode and precision, as well as constant values, and is used with expr! macro.

Implementations§

Source§

impl Context

Source

pub fn new( p: usize, rm: RoundingMode, cc: Consts, emin: i32, emax: i32, ) -> Context

Create a new context. The value of emin will be clamped to a range between EXPONENT_MIN and 0. The value of emax will be clamped to a range between 0 and EXPONENT_MAX.

Source

pub fn to_raw_parts(self) -> (usize, RoundingMode, Consts, i32, i32)

Destructures the context and returns its parts: target precision, rounding mode, constant cache, minimum exponent, maximum exponent.

Source

pub fn set_precision(&mut self, p: usize)

Sets the precision of the context.

Source

pub fn set_rounding_mode(&mut self, rm: RoundingMode)

Sets the rounding mode of the context.

Source

pub fn set_consts(&mut self, cc: Consts)

Sets the constant cache of the context.

Source

pub fn set_emin(&mut self, emin: i32)

Sets the minimum exponent. The value of emin will be clamped to a range between EXPONENT_MIN and 0.

Source

pub fn set_emax(&mut self, emax: i32)

Sets the maximum exponent. The value of emax will be clamped to a range between 0 and EXPONENT_MAX.

Source

pub fn precision(&self) -> usize

Returns the precision of the context.

Source

pub fn rounding_mode(&self) -> RoundingMode

Returns the rounding mode of the context.

Source

pub fn consts(&mut self) -> &mut Consts

Returns a mutable reference to the constant cache of the context.

Source

pub fn const_pi(&mut self) -> BigFloat

Returns the value of the pi number.

Source

pub fn const_e(&mut self) -> BigFloat

Returns the value of the Euler number.

Source

pub fn const_ln2(&mut self) -> BigFloat

Returns the value of the natural logarithm of 2.

Source

pub fn const_ln10(&mut self) -> BigFloat

Returns the value of the natural logarithm of 10.

Source

pub fn emin(&self) -> i32

Returns the minimum exponent.

Source

pub fn emax(&self) -> i32

Returns the maximum exponent.

Source

pub fn clone(&self) -> Result<Context, Error>

Clones self and returns the cloned context.

§Errors
  • MemoryAllocation: failed to allocate memory for the constants cache.

Trait Implementations§

Source§

impl Contextable for Context

Source§

fn precision(&self) -> usize

Returns the precision of the context.
Source§

fn rounding_mode(&self) -> RoundingMode

Returns the rounding mode of the context.
Source§

fn consts(&mut self) -> &mut Consts

Returns a mutable reference to the constant cache of the context.
Source§

fn const_pi(&mut self) -> BigFloat

Returns the value of the pi number.
Source§

fn const_e(&mut self) -> BigFloat

Returns the value of the Euler number.
Source§

fn const_ln2(&mut self) -> BigFloat

Returns the value of the natural logarithm of 2.
Source§

fn const_ln10(&mut self) -> BigFloat

Returns the value of the natural logarithm of 10.
Source§

fn emin(&self) -> i32

Returns the minimum exponent.
Source§

fn emax(&self) -> i32

Returns the maximum exponent.
Source§

impl Debug for Context

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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> 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