Crate num_bigfloat
source · [−]Expand description
Multiple precision floating point numbers implemented purely in Rust. Number has fixed-size mantissa and exponent, but increased precision compared to f32 or f64 values.
Number characteristics:
Name | Value |
---|---|
Decimal positions in mantissa | 40 |
Exponent minimum value | -128 |
Exponent maximum value | 127 |
Examples
use num_bigfloat::BigFloat;
use num_bigfloat::ONE;
use num_bigfloat::PI;
// compute pi: pi = 6*arctan(1/sqrt(3))
let six: BigFloat = 6.0.into(); // note: conversion from f64,f32 are not loss-less.
let three: BigFloat = BigFloat::parse("3.0").unwrap();
let pi = six * (ONE / three.sqrt()).atan();
let epsilon = 1.0e-38.into();
assert!((pi - PI).abs() < epsilon);
println!("{}", pi);
// output: 3.141592653589793238462643383279502884196e-39
Performance
The fixed-size mantissa allowed the introduction of precomputed tables to speed up most calculations. With regard to anything else, the implementation is straightforward.
no_std
Library can be used without the standard Rust library. This can be achieved by turning off std
feature.
Structs
Number representation.
Constants
Euler’s number.
PI/2
Negative infinity.
Positive infinity.
Maximum value possible.
Maximum possible exponent.
Minumum value possible.
Minumum possible exponent.
Smalles positive number.
NaN representation.
Value of one.
PI number.
Radix of BigFloat
Value of two.
Value of zero.