# Library for multiple precision floating point numbers

A minimalistic implementation for multiple precision floating point numbers.
Numbers can hold up-to 40 decimal positions with decimal exponent in range -128..127. Crate includes basic functions, like sqrt, pow, ln, sin, cos.

1 Like

Out of curiosity, how does this compare to rust_recimal other than the differences between floats and decimals themselves?

1 Like

Well, you said the difference. Decimal has more limited range of values compared to float.

Here is an example actually of how num-bigfloat is essentially different. Lets calculate sin and cos. Then to verify the precision `sin * sin + cos * cos = 1`. And here is what we have:

``````// rust_decimal
pub fn test_decimal() {
let d1 = Decimal::from_f64_retain(2.100000000000000005551115123).unwrap();
let s = d1.sin();
let c = d1.cos();
println!("{}", s*s + c*c);
}
// prints: 0.9999999999982223922390866348
``````
``````// num-bigfloat
pub fn test_bigfloat() {
let d1 = BigFloat::from_f64(2.100000000000000005551115123).unwrap();
let s = d1.sin().unwrap();
let c = d1.cos().unwrap();