Expand description
§bigfloat
A safe, production-ready wrapper around MPFR for arbitrary-precision floating-point arithmetic.
This crate provides a BigFloat type that supports high‑precision floating‑point operations.
All basic arithmetic (addition, subtraction, multiplication, division) is available through
operator overloading, and many mathematical functions (such as sqrt, sin, log, factorial,
constants, etc.) are exposed as free functions. Precision can be specified either by the number
of bits or by the desired number of decimal digits.
§Examples
use bigfloat::*;
let x = "123.456".to_bigfloat(256);
let y = "789.012".to_bigfloat(256);
let sum = &x + &y;
assert_eq!(sum.to_string(10), "912.468");
let pi = const_pi(Some(50));
println!("π ≈ {pi}");Structs§
- BigFloat
- An arbitrary‑precision floating‑point number backed by an MPFR variable.
Traits§
Functions§
- acos
- Returns the arccosine (inverse cosine) of
nradians. - add
- Returns the sum of two values, with
digitsdecimal digits of precision (default 500). - asin
- Returns the arcsine (inverse sine) of
nradians. - atan
- Returns the arctangent (inverse tangent) of
nradians. - const_e
- Returns e (Euler’s number) to
ddecimal digits of precision (default 500). - const_
pi - Returns π (pi) to
ddecimal digits of precision (default 500). - cos
- Returns the cosine of
nradians. - deg_
to_ rad - Converts degrees to radians.
- div
- Returns the quotient
a / b, withdigitsdecimal digits of precision (default 500). - factorial
- Returns the factorial of
n,n!, computed viaΓ(n+1). - ln
- Returns the ln of
n(ln(n)). - ln_
factorial - Returns the natural logarithm of the factorial (
ln(n!)). - log
- Returns the base‑10 logarithm of
n(log10(n)). - log2
- Returns the base‑2 logarithm of
n(log2(n)). - mul
- Returns the product
a * b, withdigitsdecimal digits of precision (default 500). - pow
- Returns the result of raising
bto the powerp(b^p). - rad_
to_ deg - Converts radians to degrees.
- root
- Returns the
n‑th root ofb(i.e.,b^(1/n)) withddecimal digits of precision. - sin
- Returns the sine of
nradians. - sqrt
- Returns the square root of
nwithddecimal digits of precision (default 500). - sub
- Returns the difference
a - b, withdigitsdecimal digits of precision (default 500). - tan
- Returns the tangent of
nradians.