Crates.io | break_infinity |
lib.rs | break_infinity |
version | 0.4.0 |
source | src |
created_at | 2020-12-19 13:54:04.167625 |
updated_at | 2024-08-04 07:58:21.247963 |
description | A library for larger numbers up to 1e9e15 in Rust for Incremental Games |
homepage | https://github.com/redfire75369/break-infinity.rs#readme |
repository | https://github.com/redfire75369/break-infinity.rs |
max_upload_size | |
id | 324562 |
size | 58,470 |
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.
You can install this package via Cargo by adding these lines to your Cargo.toml
.
[dependencies]
break_infinity = "0.3.0"
# ...
full-range
: Increases maximum value to 1e1.79e308. Reduced accuracy above 1e9e15serde
: Enables Serialization and Deserialization with SerdeThis 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.
Patashu and Razenpok for creating the original break_infinity.js
that this is based off of.