Crates.io | omeganum |
lib.rs | omeganum |
version | |
source | src |
created_at | 2024-10-15 20:37:56.850027 |
updated_at | 2024-10-15 20:44:26.46906 |
description | Stores numbers up to 10{N}9e15. |
homepage | |
repository | https://github.com/balt-dev/omeganum |
max_upload_size | |
id | 1410314 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This is a direct port of Naruyoko's OmegaNum.js to Rust.
Using this library, you are able to store numbers up to 10{N}9e15 in Bower's operator notation, with no hard limit on N. Note that some functions (for example, the gamma function) are left unimplemented. I may add them in later.
This crate supports #![no-std]
.
default
: Enables std
std
: Enables using the standard libraryerror_in_core
: Enables implementing the recently stabilized1 core::error::Error
on error types when std
is not enabledlibm
: Required without std
enabled for mathserde
: Enables support for serde::Serialize
and serde::Deserialize
f16
: Enables support for converting from the experimental f16
typeAn f128
feature is planned for when that type gains the necessary method log10
.
use omeganum::{OmegaNum, constant};
use std::borrow::Cow;
// Create constants like this:
const ONE: OmegaNum = constant!(1);
// or like this:
const TEN_E_TWENTY: OmegaNum = OmegaNum::from_parts(
// The base and array are stored separately,
// which makes numerous operations much faster by avoiding
// accessing the heap
1.0, Cow::Borrowed(&[20.0])
);
// Numbers will coerce to OmegaNum when operated with them
assert_eq!(ONE + 1, 2);
// ONE + OmegaNum::from(1) == OmegaNum::from(2)
// Math operations move the value, requiring explicitly defined cloning
let seventeen = OmegaNum::from(17);
let log10_17 = seventeen.log10();
// The below code doesn't work, as log10 consumed seventeen
// println!("log10 {seventeen} is {log10_seventeen}");
// Instead, do this:
let seventeen = OmegaNum::from(17);
let log10_17 = seventeen.clone().log10();
println!("log10 {seventeen} is {log10_17}");
// Constants store their arrays statically:
let c = constant!(7);
assert!(matches!(c.into_parts().1, Cow::Borrowed(_)));
This project is under the MIT license, which can be found at the root of the repository under LICENSE
.
Additionally, the license of OmegaNum.js, the work this is derived from, can be found at LICENSE-OMEGANUM
- it is also licensed under the MIT license.
in Rust version 1.81.0 ↩