5 releases (3 breaking)
0.4.0 | Aug 4, 2024 |
---|---|
0.3.0 | Oct 5, 2021 |
0.2.1 | Mar 6, 2021 |
0.2.0 | Feb 27, 2021 |
0.1.0 | Dec 19, 2020 |
#409 in Math
38KB
944 lines
break-infinity.rs
A port of Patashu's break_infinity.js to Rust.
It has the Decimal
struct which is able to reach a maximum value of 1e9e15 instead of f64
's maximum of 1.79e308.
Installation
You can install this package via Cargo by adding these lines to your Cargo.toml
.
[dependencies]
break_infinity = "0.3.0"
# ...
Features
full-range
: Increases maximum value to 1e1.79e308. Reduced accuracy above 1e9e15serde
: Enables Serialization and Deserialization with Serde
Usage
This library allows simple creation of Decimal
's through many different methods.
use break_infinity::Decimal;
fn main() {
let x = Decimal::new(123.4567);
let y = Decimal::from_str("123456.7e-3").expect("Failed to parse Decimal");
}
Methods that return a Decimal
can also be chained
use break_infinity as bi;
fn main() {
let short = ((x / &y + &z) * &Decimal::new(9.0)).floor();
let long = x.ceil()
.exp()
.log10();
}
For a complete list of functions and methods, refer to the docs.
Acknowledgements
Patashu and Razenpok for creating the original break_infinity.js
that this is based off of.
Dependencies
~170KB