Struct astro_float::ctx::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
impl Context
sourcepub fn new(
p: usize,
rm: RoundingMode,
cc: Consts,
emin: i32,
emax: i32
) -> Context
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.
sourcepub fn to_raw_parts(self) -> (usize, RoundingMode, Consts, i32, i32)
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.
sourcepub fn set_precision(&mut self, p: usize)
pub fn set_precision(&mut self, p: usize)
Sets the precision of the context.
sourcepub fn set_rounding_mode(&mut self, rm: RoundingMode)
pub fn set_rounding_mode(&mut self, rm: RoundingMode)
Sets the rounding mode of the context.
sourcepub fn set_consts(&mut self, cc: Consts)
pub fn set_consts(&mut self, cc: Consts)
Sets the constant cache of the context.
sourcepub fn set_emin(&mut self, emin: i32)
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.
sourcepub fn set_emax(&mut self, emax: i32)
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.
sourcepub fn rounding_mode(&self) -> RoundingMode
pub fn rounding_mode(&self) -> RoundingMode
Returns the rounding mode of the context.
sourcepub fn consts(&mut self) -> &mut Consts
pub fn consts(&mut self) -> &mut Consts
Returns a mutable reference to the constant cache of the context.
sourcepub fn const_ln10(&mut self) -> BigFloat
pub fn const_ln10(&mut self) -> BigFloat
Returns the value of the natural logarithm of 10.