Struct astro_float::BigFloat
source · pub struct BigFloat { /* private fields */ }Expand description
A floating point number of arbitrary precision.
Implementations§
source§impl BigFloat
impl BigFloat
sourcepub fn new(p: usize) -> BigFloat
pub fn new(p: usize) -> BigFloat
Returns a new number with value of 0 and precision of p bits. Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn from_f64(f: f64, p: usize) -> BigFloat
pub fn from_f64(f: f64, p: usize) -> BigFloat
Constructs a number with precision p from f64 value.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn nan(err: Option<Error>) -> BigFloat
pub fn nan(err: Option<Error>) -> BigFloat
Constructs not-a-number with an associated error err.
sourcepub fn from_f32(f: f32, p: usize) -> BigFloat
pub fn from_f32(f: f32, p: usize) -> BigFloat
Constructs a number with precision p from f32 value.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn is_inf_pos(&self) -> bool
pub fn is_inf_pos(&self) -> bool
Returns true if self is positive infinity.
sourcepub fn is_inf_neg(&self) -> bool
pub fn is_inf_neg(&self) -> bool
Returns true if self is negative infinity.
sourcepub fn add(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
pub fn add(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
Adds d2 to self and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn add_full_prec(&self, d2: &BigFloat) -> BigFloat
pub fn add_full_prec(&self, d2: &BigFloat) -> BigFloat
Adds d2 to self and returns the result of the operation.
The resulting precision is equal to the full precision of the result.
This operation can be used to emulate integer addition.
sourcepub fn sub(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
pub fn sub(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
Subtracts d2 from self and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn sub_full_prec(&self, d2: &BigFloat) -> BigFloat
pub fn sub_full_prec(&self, d2: &BigFloat) -> BigFloat
Subtracts d2 from self and returns the result of the operation.
The resulting precision is equal to the full precision of the result.
This operation can be used to emulate integer subtraction.
sourcepub fn mul(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
pub fn mul(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
Multiplies d2 by self and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn mul_full_prec(&self, d2: &BigFloat) -> BigFloat
pub fn mul_full_prec(&self, d2: &BigFloat) -> BigFloat
Multiplies d2 by self and returns the result of the operation.
The resulting precision is equal to the full precision of the result.
This operation can be used to emulate integer multiplication.
sourcepub fn div(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
pub fn div(&self, d2: &BigFloat, p: usize, rm: RoundingMode) -> BigFloat
Divides self by d2 and returns the result of the operation with precision p rounded according to rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn rem(&self, d2: &BigFloat) -> BigFloat
pub fn rem(&self, d2: &BigFloat) -> BigFloat
Returns the remainder of division of |self| by |d2|. The sign of the result is set to the sign of self.
sourcepub fn cmp(&self, d2: &BigFloat) -> Option<i128>
pub fn cmp(&self, d2: &BigFloat) -> Option<i128>
Compares self to d2.
Returns positive if self > d2, negative if self < d2, zero if self == d2, None if self or d2 is NaN.
sourcepub fn abs_cmp(&self, d2: &BigFloat) -> Option<i128>
pub fn abs_cmp(&self, d2: &BigFloat) -> Option<i128>
Compares the absolute value of self to the absolute value of d2.
Returns positive if |self| is greater than |d2|, negative if |self| is smaller than |d2|, 0 if |self| equals to |d2|, None if self or d2 is NaN.
sourcepub fn pow(
&self,
n: &BigFloat,
p: usize,
rm: RoundingMode,
cc: &mut Consts
) -> BigFloat
pub fn pow( &self, n: &BigFloat, p: usize, rm: RoundingMode, cc: &mut Consts ) -> BigFloat
Compute the power of self to the n with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn powi(&self, n: usize, p: usize, rm: RoundingMode) -> BigFloat
pub fn powi(&self, n: usize, p: usize, rm: RoundingMode) -> BigFloat
Compute the power of self to the integer n with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn log(
&self,
n: &BigFloat,
p: usize,
rm: RoundingMode,
cc: &mut Consts
) -> BigFloat
pub fn log( &self, n: &BigFloat, p: usize, rm: RoundingMode, cc: &mut Consts ) -> BigFloat
Computes the logarithm base n of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if self is positive.
The function returns false if self is NaN.
sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if self is negative.
The function returns false if self is NaN.
sourcepub fn is_subnormal(&self) -> bool
pub fn is_subnormal(&self) -> bool
Returns true if self is subnormal. A number is subnormal if the most significant bit of the mantissa is not equal to 1.
sourcepub fn clamp(&self, min: &BigFloat, max: &BigFloat) -> BigFloat
pub fn clamp(&self, min: &BigFloat, max: &BigFloat) -> BigFloat
Restricts the value of self to an interval determined by the values of min and max.
The function returns max if self is greater than max, min if self is less than min, and self otherwise.
If either argument is NaN or min is greater than max, the function returns NaN.
sourcepub fn max(&self, d1: &BigFloat) -> BigFloat
pub fn max(&self, d1: &BigFloat) -> BigFloat
Returns the value of d1 if d1 is greater than self, or the value of self otherwise.
If either argument is NaN, the function returns NaN.
sourcepub fn min(&self, d1: &BigFloat) -> BigFloat
pub fn min(&self, d1: &BigFloat) -> BigFloat
Returns value of d1 if d1 is less than self, or the value of self otherwise.
If either argument is NaN, the function returns NaN.
sourcepub fn signum(&self) -> BigFloat
pub fn signum(&self) -> BigFloat
Returns a BigFloat with the value -1 if self is negative, 1 if self is positive, zero otherwise.
The function returns NaN If self is NaN.
sourcepub fn parse(
s: &str,
rdx: Radix,
p: usize,
rm: RoundingMode,
cc: &mut Consts
) -> BigFloat
pub fn parse( s: &str, rdx: Radix, p: usize, rm: RoundingMode, cc: &mut Consts ) -> BigFloat
Parses a number from the string s.
The function expects s to be a number in scientific format in base 10, or +-Inf, or NaN.
if p equals to usize::MAX then the precision of the resulting number is determined automatically from the input.
Examples
let mut cc = Consts::new().expect("Constants cache initialized.");
let n = BigFloat::parse("0.0", Radix::Bin, 64, RoundingMode::ToEven, &mut cc);
assert!(n.is_zero());
let n = BigFloat::parse("1.124e-24", Radix::Dec, 128, RoundingMode::ToEven, &mut cc);
assert!(n.sub(&BigFloat::from_f64(1.124e-24, 128), 128, RoundingMode::ToEven).exponent() <= Some(-52 - 24));
let n = BigFloat::parse("-Inf", Radix::Hex, 1, RoundingMode::None, &mut cc);
assert!(n.is_inf_neg());
let n = BigFloat::parse("NaN", Radix::Oct, 2, RoundingMode::None, &mut cc);
assert!(n.is_nan());sourcepub fn format(
&self,
rdx: Radix,
rm: RoundingMode,
cc: &mut Consts
) -> Result<String, Error>
pub fn format( &self, rdx: Radix, rm: RoundingMode, cc: &mut Consts ) -> Result<String, Error>
Formats the number using radix rdx and rounding mode rm.
Note, since hexadecimal digits include the character “e”, the exponent part is separated
from the mantissa by “_”.
For example, a number with mantissa 123abcdef and exponent 123 would be formatted as 123abcdef_e+123.
Errors
- MemoryAllocation: failed to allocate memory for mantissa.
- ExponentOverflow: the resulting exponent becomes greater than the maximum allowed value for the exponent.
sourcepub fn random_normal(p: usize, exp_from: i32, exp_to: i32) -> BigFloat
pub fn random_normal(p: usize, exp_from: i32, exp_to: i32) -> BigFloat
Returns a random normalized (not subnormal) BigFloat number with exponent in the range
from exp_from to exp_to inclusive. The sign can be positive and negative. Zero is excluded.
Precision is rounded upwards to the word size.
Function does not follow any specific distribution law.
The intended use of this function is for testing.
The function returns NaN if the precision p is incorrect or when exp_from is less than EXPONENT_MIN or exp_to is greater than EXPONENT_MAX.
sourcepub fn classify(&self) -> FpCategory
pub fn classify(&self) -> FpCategory
Returns category of self.
sourcepub fn atan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn atan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the arctangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn tanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn tanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the hyperbolic tangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn exponent(&self) -> Option<i32>
pub fn exponent(&self) -> Option<i32>
Returns the exponent of self, or None if self is Inf or NaN.
sourcepub fn precision(&self) -> Option<usize>
pub fn precision(&self) -> Option<usize>
Returns the number of significant bits used in the mantissa, or None if self is Inf or NaN.
Normal numbers use all bits of the mantissa.
Subnormal numbers use fewer bits than the mantissa can hold.
sourcepub fn max_value(p: usize) -> BigFloat
pub fn max_value(p: usize) -> BigFloat
Returns the maximum value for the specified precision p: all bits of the mantissa are set to 1,
the exponent has the maximum possible value, and the sign is positive.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn min_value(p: usize) -> BigFloat
pub fn min_value(p: usize) -> BigFloat
Returns the minimum value for the specified precision p: all bits of the mantissa are set to 1, the exponent has the maximum possible value, and the sign is negative. Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn min_positive(p: usize) -> BigFloat
pub fn min_positive(p: usize) -> BigFloat
Returns the minimum positive subnormal value for the specified precision p:
only the least significant bit of the mantissa is set to 1, the exponent has
the minimum possible value, and the sign is positive.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn min_positive_normal(p: usize) -> BigFloat
pub fn min_positive_normal(p: usize) -> BigFloat
Returns the minimum positive normal value for the specified precision p:
only the most significant bit of the mantissa is set to 1, the exponent has
the minimum possible value, and the sign is positive.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn from_word(d: u64, p: usize) -> BigFloat
pub fn from_word(d: u64, p: usize) -> BigFloat
Returns a new number with value d and the precision p. Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn as_raw_parts(&self) -> Option<(&[u64], usize, Sign, i32, bool)>
pub fn as_raw_parts(&self) -> Option<(&[u64], usize, Sign, i32, bool)>
Decomposes self into raw parts.
The function returns a reference to a slice of words representing mantissa,
numbers of significant bits in the mantissa, sign, exponent,
and a bool value which specify whether the number is inexact.
sourcepub fn from_raw_parts(
m: &[u64],
n: usize,
s: Sign,
e: i32,
inexact: bool
) -> BigFloat
pub fn from_raw_parts( m: &[u64], n: usize, s: Sign, e: i32, inexact: bool ) -> BigFloat
Constructs a number from the raw parts:
mis the mantisaa.nis the number of significant bits in mantissa.sis the sign.eis the exponent.inexactspecify whether number is inexact.
This function returns NaN in the following situations:
nis larger than the number of bits inm.nis smaller than the number of bits inm, butmdoes not represent corresponding subnormal number mantissa.nis smaller than the number of bits inm, buteis not the minimum possible exponent.nor the size ofmis too large (larger than isize::MAX / 2 + EXPONENT_MIN).eis less than EXPONENT_MIN or greater than EXPONENT_MAX.
sourcepub fn from_words(m: &[u64], s: Sign, e: i32) -> BigFloat
pub fn from_words(m: &[u64], s: Sign, e: i32) -> BigFloat
Constructs a number from the slice of words:
mis the mantissa.sis the sign.eis the exponent.
The function returns NaN if e is less than EXPONENT_MIN or greater than EXPONENT_MAX.
sourcepub fn set_exponent(&mut self, e: i32)
pub fn set_exponent(&mut self, e: i32)
Sets the exponent of self.
Note that if self is subnormal, the exponent may not change, but the mantissa will shift instead.
e will be clamped to the range from EXPONENT_MIN to EXPONENT_MAX if it’s outside of the range.
See example below.
Examples
// construct a subnormal value.
let mut n = BigFloat::min_positive(128);
assert_eq!(n.exponent(), Some(EXPONENT_MIN));
assert_eq!(n.precision(), Some(1));
// increase exponent.
let n_exp = n.exponent().expect("n is not NaN");
n.set_exponent(n_exp + 1);
// the outcome for subnormal number.
assert_eq!(n.exponent(), Some(EXPONENT_MIN));
assert_eq!(n.precision(), Some(2));sourcepub fn mantissa_max_bit_len(&self) -> Option<usize>
pub fn mantissa_max_bit_len(&self) -> Option<usize>
Returns the maximum mantissa length of self in bits regardless of whether self is normal or subnormal.
sourcepub fn set_precision(&mut self, p: usize, rm: RoundingMode) -> Result<(), Error>
pub fn set_precision(&mut self, p: usize, rm: RoundingMode) -> Result<(), Error>
Sets the precision of self to p.
If the new precision is smaller than the existing one, the number is rounded using specified rounding mode rm.
Errors
- MemoryAllocation: failed to allocate memory for mantissa.
- InvalidArgument: the precision is incorrect.
sourcepub fn reciprocal(&self, p: usize, rm: RoundingMode) -> BigFloat
pub fn reciprocal(&self, p: usize, rm: RoundingMode) -> BigFloat
Computes the reciprocal of a number with precision p.
The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size.
The function returns NaN if the precision p is incorrect.
sourcepub fn mantissa_digits(&self) -> Option<&[u64]>
pub fn mantissa_digits(&self) -> Option<&[u64]>
Returns the raw mantissa words of a number.
sourcepub fn convert_from_radix(
sign: Sign,
digits: &[u8],
e: i32,
rdx: Radix,
p: usize,
rm: RoundingMode,
cc: &mut Consts
) -> BigFloat
pub fn convert_from_radix( sign: Sign, digits: &[u8], e: i32, rdx: Radix, p: usize, rm: RoundingMode, cc: &mut Consts ) -> BigFloat
Converts an array of digits in radix rdx to BigFloat with precision p.
digits represents mantissa and is interpreted as a number smaller than 1 and greater or equal to 1/rdx.
The first element in digits is the most significant digit.
e is the exponent part of the number, such that the number can be represented as digits * rdx ^ e.
Precision is rounded upwards to the word size.
if p equals usize::MAX then the precision of the resulting number is determined automatically from the input.
Examples
Code below converts -0.1234567₈ × 10₈^3₈ given in radix 8 to BigFloat.
let mut cc = Consts::new().expect("Constants cache initialized.");
let g = BigFloat::convert_from_radix(
Sign::Neg,
&[1, 2, 3, 4, 5, 6, 7, 0],
3,
Radix::Oct,
64,
RoundingMode::None,
&mut cc);
let n = BigFloat::from_f64(-83.591552734375, 64);
assert_eq!(n.cmp(&g), Some(0));Errors
On error, the function returns NaN with the following associated error:
- MemoryAllocation: failed to allocate memory for mantissa.
- ExponentOverflow: the resulting exponent becomes greater than the maximum allowed value for the exponent.
- InvalidArgument: the precision is incorrect, or
digitscontains unacceptable digits for given radix, or wheneis less than EXPONENT_MIN or greater than EXPONENT_MAX.
sourcepub fn convert_to_radix(
&self,
rdx: Radix,
rm: RoundingMode,
cc: &mut Consts
) -> Result<(Sign, Vec<u8>, i32), Error>
pub fn convert_to_radix( &self, rdx: Radix, rm: RoundingMode, cc: &mut Consts ) -> Result<(Sign, Vec<u8>, i32), Error>
Converts self to radix rdx using rounding mode rm.
The function returns sign, mantissa digits in radix rdx, and exponent such that the converted number
can be represented as mantissa digits * rdx ^ exponent.
The first element in the mantissa is the most significant digit.
Examples
let n = BigFloat::from_f64(0.00012345678f64, 64);
let mut cc = Consts::new().expect("Constants cache initialized.");
let (s, m, e) = n.convert_to_radix(Radix::Dec, RoundingMode::None, &mut cc).expect("Conversion failed");
assert_eq!(s, Sign::Pos);
assert_eq!(m, [1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 4]);
assert_eq!(e, -3);Errors
- MemoryAllocation: failed to allocate memory for mantissa.
- ExponentOverflow: the resulting exponent becomes greater than the maximum allowed value for the exponent.
- InvalidArgument:
selfis Inf or NaN.
sourcepub fn inexact(&self) -> bool
pub fn inexact(&self) -> bool
Returns true if self is inexact. The function returns false if self is Inf or NaN.
sourcepub fn set_inexact(&mut self, inexact: bool)
pub fn set_inexact(&mut self, inexact: bool)
Marks self as inexact if inexact is true, or exact otherwise.
The function has no effect if self is Inf or NaN.
sourcepub fn try_set_precision(
&mut self,
p: usize,
rm: RoundingMode,
s: usize
) -> bool
pub fn try_set_precision( &mut self, p: usize, rm: RoundingMode, s: usize ) -> bool
Try to round and then set the precision to p, given self has s correct digits in mantissa.
The function returns true if rounding succeeded, or if self is Inf or NaN.
If the fuction returns false, self is still modified, and should be discarded.
In case of an error, self will be set to NaN with an associated error.
If the precision p is incorrect self will be set to NaN.
source§impl BigFloat
impl BigFloat
sourcepub fn round(&self, n: usize, rm: RoundingMode) -> BigFloat
pub fn round(&self, n: usize, rm: RoundingMode) -> BigFloat
Returns the rounded number with n binary positions in the fractional part of the number using rounding mode rm.
sourcepub fn sqrt(&self, p: usize, rm: RoundingMode) -> BigFloat
pub fn sqrt(&self, p: usize, rm: RoundingMode) -> BigFloat
Computes the square root of a number with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn cbrt(&self, p: usize, rm: RoundingMode) -> BigFloat
pub fn cbrt(&self, p: usize, rm: RoundingMode) -> BigFloat
Computes the cube root of a number with precision p. The result is rounded using the rounding mode rm.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn ln(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn ln(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the natural logarithm of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn log2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn log2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the logarithm base 2 of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn log10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn log10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the logarithm base 10 of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn exp(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn exp(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes e to the power of self with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn sin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn sin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the sine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn cos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn cos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the cosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn tan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn tan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the tangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn asin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn asin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the arcsine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn acos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn acos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the arccosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn sinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn sinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the hyperbolic sine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn cosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn cosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the hyperbolic cosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn asinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn asinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the hyperbolic arcsine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn acosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn acosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the hyperbolic arccosine of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
sourcepub fn atanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
pub fn atanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> BigFloat
Computes the hyperbolic arctangent of a number with precision p. The result is rounded using the rounding mode rm.
This function requires constants cache cc for computing the result.
Precision is rounded upwards to the word size. The function returns NaN if the precision p is incorrect.
Trait Implementations§
source§impl<'de> Deserialize<'de> for BigFloat
impl<'de> Deserialize<'de> for BigFloat
source§fn deserialize<D>(
deserializer: D
) -> Result<BigFloat, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<BigFloat, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<'a> PartialEq<&'a BigFloat> for BigFloat
impl<'a> PartialEq<&'a BigFloat> for BigFloat
source§impl PartialEq for BigFloat
impl PartialEq for BigFloat
source§impl<'a> PartialOrd<&'a BigFloat> for BigFloat
impl<'a> PartialOrd<&'a BigFloat> for BigFloat
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl PartialOrd for BigFloat
impl PartialOrd for BigFloat
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more