Struct num_bigfloat::BigFloat
source · [−]pub struct BigFloat { /* private fields */ }
Expand description
Number representation.
Implementations
sourceimpl BigFloat
impl BigFloat
sourcepub fn from_bytes(bytes: &[u8], sign: i8, exponent: i8) -> BigFloat
pub fn from_bytes(bytes: &[u8], sign: i8, exponent: i8) -> BigFloat
Create a BigFloat value from a sequence of bytes
. Each byte must represent a decimal digit.
First byte is the most significant. The length of bytes
can be any. If the length of
bytes
is greater than required, then the remaining part is ignored.
If sign
is negative, then the resulting BigFloat will be
negative.
sourcepub fn from_f32(f: f32) -> Result<Self, Error>
pub fn from_f32(f: f32) -> Result<Self, Error>
Construct BigFloat from f32. Wrapper for from_f64.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn get_mantissa_bytes(&self, bytes: &mut [u8])
pub fn get_mantissa_bytes(&self, bytes: &mut [u8])
Get BigFloat’s mantissa as bytes. Each byte represents a decimal digit.
First byte is the most significant. The length of bytes
can be any. If the length of
bytes
is smaller than required, then remaining part of mantissa will be omitted.
The length of mantissa can be determined using get_mantissa_len
.
sourcepub fn get_mantissa_len(&self) -> usize
pub fn get_mantissa_len(&self) -> usize
Return the number of decimal positions filled in the mantissa.
sourcepub fn get_exponent(&self) -> i8
pub fn get_exponent(&self) -> i8
Return exponent part.
sourcepub fn add(&self, d2: &BigFloat) -> Result<BigFloat, Error>
pub fn add(&self, d2: &BigFloat) -> Result<BigFloat, Error>
Add d2 and return result of addition.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn sub(&self, d2: &BigFloat) -> Result<BigFloat, Error>
pub fn sub(&self, d2: &BigFloat) -> Result<BigFloat, Error>
Subtract d2 and return result of subtraction.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn mul(&self, d2: &BigFloat) -> Result<BigFloat, Error>
pub fn mul(&self, d2: &BigFloat) -> Result<BigFloat, Error>
Multiply by d2 and return result of multiplication.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn div(&self, d2: &BigFloat) -> Result<BigFloat, Error>
pub fn div(&self, d2: &BigFloat) -> Result<BigFloat, Error>
Divide by d2 and return result of division.
Errors
ExponentOverflow - when result is too big or too small. DivisionByZero - in case of d2 equal to zero.
sourcepub fn pow(&self, d1: &BigFloat) -> Result<BigFloat, Error>
pub fn pow(&self, d1: &BigFloat) -> Result<BigFloat, Error>
Return BigFloat to the power of d1
.
Errors
ExponentOverflow - when result is too big or too small.
ArgumentIsNegative - when d1
has fractional part and self
is negative.
sourcepub fn ln(&self) -> Result<BigFloat, Error>
pub fn ln(&self) -> Result<BigFloat, Error>
Returns natural logarithm of a number.
Errors
ExponentOverflow - when result is too big or too small.
InvalidArgument - when self
is negative or zero.
sourcepub fn sin(&self) -> Result<BigFloat, Error>
pub fn sin(&self) -> Result<BigFloat, Error>
Returns sine of a number. Argument is an angle in radians.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn cos(&self) -> Result<BigFloat, Error>
pub fn cos(&self) -> Result<BigFloat, Error>
Returns cosine of a number. Argument is an angle in radians.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn tan(&self) -> Result<BigFloat, Error>
pub fn tan(&self) -> Result<BigFloat, Error>
Returns tangent of a number. Argument is an angle in radians.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn asin(&self) -> Result<BigFloat, Error>
pub fn asin(&self) -> Result<BigFloat, Error>
Returns arcsine of a number. Result is an angle in radians ranging from -pi
to pi
.
Errors
ExponentOverflow - when result is too big or too small.
InvalidArgument - when |self
| > 1.
sourcepub fn acos(&self) -> Result<BigFloat, Error>
pub fn acos(&self) -> Result<BigFloat, Error>
Returns arccosine of a number.
Errors
ExponentOverflow - when result is too big or too small.
InvalidArgument - when |self
| > 1.
sourcepub fn cosh(&self) -> Result<BigFloat, Error>
pub fn cosh(&self) -> Result<BigFloat, Error>
Returns hyperbolic cosine of a number.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn tanh(&self) -> Result<BigFloat, Error>
pub fn tanh(&self) -> Result<BigFloat, Error>
Returns hyperbolic tangent of a number.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn asinh(&self) -> Result<BigFloat, Error>
pub fn asinh(&self) -> Result<BigFloat, Error>
Returns inverse hyperbolic sine of a number.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn acosh(&self) -> Result<BigFloat, Error>
pub fn acosh(&self) -> Result<BigFloat, Error>
Returns inverse hyperbolic cosine of a number.
Errors
ExponentOverflow - when result is too big or too small.
InvalidArgument - when self
is less than 1.
sourcepub fn atanh(&self) -> Result<BigFloat, Error>
pub fn atanh(&self) -> Result<BigFloat, Error>
Returns inverse hyperbolic tangent of a number.
Errors
ExponentOverflow - when result is too big or too small.
InvalidArgument - when |self
| >= 1.
sourcepub fn floor(&self) -> Result<Self, Error>
pub fn floor(&self) -> Result<Self, Error>
Returns the largest integer less than or equal to a number.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn ceil(&self) -> Result<Self, Error>
pub fn ceil(&self) -> Result<Self, Error>
Returns the smallest integer greater than or equal to a number.
Errors
ExponentOverflow - when result is too big or too small.
sourcepub fn frac(&self) -> Self
pub fn frac(&self) -> Self
Return fractional part of a number, i.e. having self=12.345 it will return 0.345.
sourcepub fn int(&self) -> Self
pub fn int(&self) -> Self
Return integer part of a number, i.e. having self=12.345 it will return 12.0.
sourcepub fn round(&self, n: usize) -> Result<Self, Error>
pub fn round(&self, n: usize) -> Result<Self, Error>
Returns the rounded number with n
decimal positions in the fractional part of the number.
sourcepub fn cmp(&self, d2: &BigFloat) -> i16
pub fn cmp(&self, d2: &BigFloat) -> i16
Compare to d2. Returns positive if self > d2, negative if self < d2, 0 otherwise.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BigFloat
impl Send for BigFloat
impl Sync for BigFloat
impl Unpin for BigFloat
impl UnwindSafe for BigFloat
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more