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) -> Self
pub fn new(p: usize) -> Self
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) -> Self
pub fn from_f64(f: f64, p: usize) -> Self
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 from_f32(f: f32, p: usize) -> Self
pub fn from_f32(f: f32, p: usize) -> Self
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: &Self, p: usize, rm: RoundingMode) -> Self
pub fn add(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
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: &Self) -> Self
pub fn add_full_prec(&self, d2: &Self) -> Self
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: &Self, p: usize, rm: RoundingMode) -> Self
pub fn sub(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
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: &Self) -> Self
pub fn sub_full_prec(&self, d2: &Self) -> Self
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: &Self, p: usize, rm: RoundingMode) -> Self
pub fn mul(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
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: &Self) -> Self
pub fn mul_full_prec(&self, d2: &Self) -> Self
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: &Self, p: usize, rm: RoundingMode) -> Self
pub fn div(&self, d2: &Self, p: usize, rm: RoundingMode) -> Self
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: &Self) -> Self
pub fn rem(&self, d2: &Self) -> Self
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: &Self) -> Option<i128>
pub fn abs_cmp(&self, d2: &Self) -> 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: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn pow(&self, n: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn powi(&self, n: usize, p: usize, rm: RoundingMode) -> Self
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: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
pub fn log(&self, n: &Self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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: &Self, max: &Self) -> Self
pub fn clamp(&self, min: &Self, max: &Self) -> Self
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: &Self) -> Self
pub fn max(&self, d1: &Self) -> Self
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: &Self) -> Self
pub fn min(&self, d1: &Self) -> Self
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) -> Self
pub fn signum(&self) -> Self
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,
) -> Self
pub fn parse( s: &str, rdx: Radix, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
Parses a number from the string s
.
The function expects s
to be a number in scientific format in radix rdx
, 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: Exponent, exp_to: Exponent) -> Self
pub fn random_normal(p: usize, exp_from: Exponent, exp_to: Exponent) -> Self
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) -> Self
pub fn atan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn tanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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<Exponent>
pub fn exponent(&self) -> Option<Exponent>
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) -> Self
pub fn max_value(p: usize) -> Self
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) -> Self
pub fn min_value(p: usize) -> Self
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) -> Self
pub fn min_positive(p: usize) -> Self
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) -> Self
pub fn min_positive_normal(p: usize) -> Self
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: Word, p: usize) -> Self
pub fn from_word(d: Word, p: usize) -> Self
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<(&[Word], usize, Sign, Exponent, bool)>
pub fn as_raw_parts(&self) -> Option<(&[Word], usize, Sign, Exponent, 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: &[Word],
n: usize,
s: Sign,
e: Exponent,
inexact: bool,
) -> Self
pub fn from_raw_parts( m: &[Word], n: usize, s: Sign, e: Exponent, inexact: bool, ) -> Self
Constructs a number from the raw parts:
m
is the mantisaa.n
is the number of significant bits in mantissa.s
is the sign.e
is the exponent.inexact
specify whether number is inexact.
This function returns NaN in the following situations:
n
is larger than the number of bits inm
.n
is smaller than the number of bits inm
, butm
does not represent corresponding subnormal number mantissa.n
is smaller than the number of bits inm
, bute
is not the minimum possible exponent.n
or the size ofm
is too large (larger than isize::MAX / 2 + EXPONENT_MIN).e
is less than EXPONENT_MIN or greater than EXPONENT_MAX.
Sourcepub fn from_words(m: &[Word], s: Sign, e: Exponent) -> Self
pub fn from_words(m: &[Word], s: Sign, e: Exponent) -> Self
Constructs a number from the slice of words:
m
is the mantissa.s
is the sign.e
is 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: Exponent)
pub fn set_exponent(&mut self, e: Exponent)
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) -> Self
pub fn reciprocal(&self, p: usize, rm: RoundingMode) -> Self
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<&[Word]>
pub fn mantissa_digits(&self) -> Option<&[Word]>
Returns the raw mantissa words of a number.
Sourcepub fn convert_from_radix(
sign: Sign,
digits: &[u8],
e: Exponent,
rdx: Radix,
p: usize,
rm: RoundingMode,
cc: &mut Consts,
) -> Self
pub fn convert_from_radix( sign: Sign, digits: &[u8], e: Exponent, rdx: Radix, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self
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
digits
contains unacceptable digits for given radix, or whene
is 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>, Exponent), Error>
pub fn convert_to_radix( &self, rdx: Radix, rm: RoundingMode, cc: &mut Consts, ) -> Result<(Sign, Vec<u8>, Exponent), 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:
self
is 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) -> Self
pub fn round(&self, n: usize, rm: RoundingMode) -> Self
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) -> Self
pub fn sqrt(&self, p: usize, rm: RoundingMode) -> Self
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) -> Self
pub fn cbrt(&self, p: usize, rm: RoundingMode) -> Self
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) -> Self
pub fn ln(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn log2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn log10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn exp(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn sin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn cos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn tan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn asin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn acos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn sinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn cosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn asinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn acosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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) -> Self
pub fn atanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self
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<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<'a> PartialOrd<&'a BigFloat> for BigFloat
impl<'a> PartialOrd<&'a BigFloat> for BigFloat
Source§impl PartialOrd for BigFloat
impl PartialOrd for BigFloat
impl Eq for BigFloat
Auto Trait Implementations§
impl Freeze for BigFloat
impl RefUnwindSafe for BigFloat
impl Send for BigFloat
impl Sync for BigFloat
impl Unpin for BigFloat
impl UnwindSafe for BigFloat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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