pub struct BigFloat { /* private fields */ }
Expand description

Number representation.

Implementations

Return new BigFloat with value zero.

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.

Construct BigFloat from f64 value. The conversion is not guaranteed to be lossless, since BigFloat and f64 have different radix.

Construct BigFloat from f32 value. The conversion is not guaranteed to be lossless, since BigFloat and f32 have different radix.

Convert BigFloat to f64.

Convert BigFloat to f32.

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. If self is Inf or NaN nothing is returned.

Return the number of decimal positions filled in the mantissa. If self is Inf or NaN 0 is returned.

Return 1 if BigFloat is positive, -1 otherwise. If self is NaN 0 is returned.

Return exponent part. If self is Inf or NaN 0 is returned.

Sets exponent part of self. Function has no effect on Inf and NaN values.

Return raw parts of BigFloat: mantissa, number of decimal positions in mantissa, sing, and exponent. If self is Inf or NaN None is returned.

Construct BigFloat from raw parts.

Return true if self is positive infinity.

Return true if self is negative infinity.

Return true if self is infinite.

Return true if self is not a number.

Add d2 and return result of addition.

Subtract d2 and return result of subtraction.

Multiply by d2 and return result of multiplication.

Divide by d2 and return result of division.

Compare to d2. Returns positive if self > d2, negative if self < d2, zero if self == d2, None if self or d2 is NaN.

Changes sign of a number to opposite.

Return BigFloat to the power of d1.

Returns true if self is positive.

Returns true if self is negative.

Returns true if self is subnormal. Number is considered subnormal if not all places of mantissa are used, and exponent has minimum possible value.

Returns true if self is zero.

Parse the number from string s. Function expects s to be a number in scientific format with base 10, or +-Inf, or NaN.

Examples
use num_bigfloat::BigFloat;
 
let n = BigFloat::parse("0.0").unwrap();
assert!(n.to_f64() == 0.0);
let n = BigFloat::parse("1.123e-123").unwrap();
assert!((n.to_f64() - 1.123e-123).abs() < f64::EPSILON);
let n = BigFloat::parse("-Inf").unwrap();
assert!(n.to_f64() == f64::NEG_INFINITY);
let n = BigFloat::parse("NaN").unwrap();
assert!(n.to_f64().is_nan());

Return absolute value.

Return integer part of a number,

Return fractional part of a number.

Returns the smallest integer greater than or equal to a number.

Returns the largest integer less than or equal to a number.

Returns the rounded number with n decimal positions in the fractional part of the number.

Return square root of a number.

Returns natural logarithm of a number.

Returns e to the power of self.

Returns sine of a number. Argument is an angle in radians.

Returns cosine of a number. Argument is an angle in radians.

Returns tangent of a number. Argument is an angle in radians.

Returns arcsine of a number. Result is an angle in radians ranging from -pi/2 to pi/2.

Returns arccosine of a number.

Returns arctangent of a number.

Returns hyperbolic sine of a number.

Returns hyperbolic cosine of a number.

Returns hyperbolic tangent of a number.

Returns inverse hyperbolic sine of a number.

Returns inverse hyperbolic cosine of a number.

Returns inverse hyperbolic tangent of a number.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.