OmegaNum.rs
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].
Features
default: Enablesstdstd: Enables using the standard libraryerror_in_core: Enables implementing the recently stabilized[^1]core::error::Erroron error types whenstdis not enabledlibm: Required withoutstdenabled for mathserde: Enables support forserde::Serializeandserde::Deserializef16: Enables support for converting from the experimentalf16type
An f128 feature is planned for when that type gains the necessary method log10.
[^1]: in Rust version 1.81.0
Usage
use ;
use Cow;
// Create constants like this:
const ONE: OmegaNum = constant!;
// or like this:
const TEN_E_TWENTY: OmegaNum = from_parts;
// Numbers will coerce to OmegaNum when operated with them
assert_eq!;
// ONE + OmegaNum::from(1) == OmegaNum::from(2)
// Math operations move the value, requiring explicitly defined cloning
let seventeen = from;
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 = from;
let log10_17 = seventeen.clone.log10;
println!;
// Constants store their arrays statically:
let c = constant!;
assert!;
Licensing
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.