COOLJAPAN
← All posts

OxiNum 0.1.3 — Arbitrary-Precision Math in Pure Rust, the GMP/MPFR-Free Way

OxiNum is the COOLJAPAN Pure-Rust arbitrary-precision math layer: bignum integers, exact rationals, high-precision floats, and complex numbers — replacing GMP, MPFR, and the rug / gmp-mpfr-sys bindings with zero C and zero FFI. Part of the NoFFI sovereign Rust stack.

release oxinum pure-rust cooljapan noffi arbitrary-precision bignum math numerics

Numbers should not need a C library to grow past 64 bits.

Today we’re releasing OxiNum 0.1.3 — the COOLJAPAN Pure-Rust arbitrary-precision math layer: bignum integers, exact rationals, high-precision floats, and arbitrary-precision complex numbers, all in one Apache-2.0 workspace.

No GMP. No MPFR. No rug. No gmp-mpfr-sys. No FFI, no -sys crates, no build-time C toolchain. Just clean, memory-safe Rust that compiles to a single static binary and goes wherever Rust goes.

Why OxiNum

For decades, “I need a bigger integer” or “I need 200 bits of π” meant reaching for GMP and MPFR — battle-tested C libraries wrapped in Rust through rug and the gmp-mpfr-sys bindings. They are fast and correct, but they come with the usual native-dependency baggage:

OxiNum ends that trade-off. It replaces rug / GMP / MPFR with a 100% Pure Rust, Apache-2.0 implementation built on top of the dashu family of crates, augmented with a fully native Pure-Rust arithmetic core. You get the precision without the FFI.

This is also the foundation SciRS2 migrated to: its high-precision paths moved off rug and onto oxinum-float, so the scientific stack now does arbitrary-precision math with no native dependency at all.

A note on scope: OxiNum is not constant-time. It is a general-purpose numerics library, not a cryptographic bignum. Secret-dependent computations (private keys, DH exponents, blinding factors) should use a constant-time library such as crypto-bigint instead.

What we built

OxiNum is a small workspace of focused crates. Each layer offers two faces: convenient dashu re-exports for everyday work, and a native Pure-Rust core when you want explicit precision and rounding control.

1. oxinum-core — the shared foundation Core traits (OxiNumTrait, OxiSigned), the OxiNumError / OxiNumResult error types, and a RoundingMode enum covering HalfEven, HalfAway, Floor, Ceil, and Truncate. The Sign type is re-exported from dashu-base.

2. oxinum-int — arbitrary-precision integers UBig and IBig re-exports plus a native BigUint / BigInt built on little-endian Vec<u64> limbs with a canonical zero invariant. Multiplication switches algorithm by size — schoolbook below 32 limbs, Karatsuba from 32 to 100, Toom-Cook-3 beyond. Division uses Knuth Algorithm D with qhat correction; GCD offers both binary (Stein’s) and Lehmer variants, plus extended GCD with Bezout coefficients. Rounding it out: Newton integer sqrt / nth-root, bitwise ops, radix I/O for bases 2–36, byte conversions, a Montgomery context for modular exponentiation, a Sieve of Eratosthenes, and primality testing via Miller-Rabin + BPSW (Jacobi and strong Lucas).

3. oxinum-float — arbitrary-precision floats FBig and DBig re-exports plus a native binary-base BigFloat with explicit precision and post-operation rounding. It ships the full transcendental set — sqrt, exp, ln, pow, sin, cos, tan, asin, acos, atan, atan2 — and high-precision constants π, e, and ln 2 computed by binary splitting / AGM. A FloatContext builder manages precision, and total_cmp gives a sort-stable total order.

4. oxinum-rational — exact rationals RBig and Relaxed re-exports plus a native BigRational with automatic GCD reduction and canonical sign/zero. The native type adds continued-fraction expansion and reconstruction, the convergents sequence, semiconvergent best-rational-approximation under a bounded denominator, and cross-domain conversions between BigFloat, BigRational, and BigInt.

5. oxinum-complex — arbitrary-precision complex CBig, a decimal-backed complex with real and imaginary parts each a DBig, supporting full arithmetic, conj, norm_sqr, and principal-branch abs, arg, exp, ln, sqrt, pow, plus complex sin/cos/tan/sinh/cosh/tanh. Alongside it, native::BigComplex rebuilds the same surface from the ground up over the binary native::BigFloat, with explicit precision and RoundingMode control.

6. oxinum — the facade A prelude re-exporting every public type, a constants module (π, e, ln 2), and parse helpers — the one crate most users add.

Getting Started

Add the facade crate:

cargo add oxinum

Or in Cargo.toml:

[dependencies]
oxinum = "0.1.3"

Integers that simply do not overflow:

use oxinum::{UBig, IBig};

let a = UBig::from(u128::MAX);
let b = UBig::from(u128::MAX);
let c = a + b;                      // 2 * u128::MAX — no overflow
println!("{c}");

let d = IBig::from(-42i64);
println!("{d}");                    // -42

Drop down to the native core for explicit-precision transcendentals:

use oxinum_float::native::{BigFloat, RoundingMode, pi};

// 200-bit π via binary splitting
let pi_200 = pi(200, RoundingMode::HalfEven);

// sin / cos at 64 bits
let x = BigFloat::from_f64(0.5, 64, RoundingMode::HalfEven).unwrap();
let sin_x = x.sin(64, RoundingMode::HalfEven);
let cos_x = x.cos(64, RoundingMode::HalfEven);

And exact rational arithmetic with continued fractions:

use oxinum_rational::native::BigRational;
use oxinum_int::native::{BigInt, BigUint};

// 415/93 = [4; 2, 6, 7]
let r = BigRational::from_parts(BigInt::from(415i64), BigUint::from_u64(93)).unwrap();
let cf = r.continued_fraction();
assert_eq!(cf, vec![BigInt::from(4i64), BigInt::from(2i64),
                    BigInt::from(6i64), BigInt::from(7i64)]);

// Best rational approximation to π with denominator ≤ 113
let pi_approx = BigRational::best_rational_approximation(&r, &BigUint::from_u64(113));

What’s inside

Tips

Part of the COOLJAPAN ecosystem

OxiNum is a member of NoFFI — the COOLJAPAN initiative to replace every C/C++/Fortran/-sys FFI dependency in the Rust ecosystem with a clean, memory-safe, 100% Pure Rust implementation. Where OxiBLAS retires OpenBLAS and LAPACK, OxiFFT retires FFT C libraries, and OxiARC retires the compression stack, OxiNum retires GMP, MPFR, and the rug / gmp-mpfr-sys bindings. Default features are 100% Pure Rust: a single static binary, no system libraries, no build-time C toolchain, WASM-friendly.

It already powers the wider stack — SciRS2 moved its high-precision paths off rug and onto oxinum-float, giving the scientific computing ecosystem arbitrary-precision math with no native dependency.

Repository: https://github.com/cool-japan/oxinum

Star the repo ⭐ if you want a future where arbitrary-precision math is sovereign again.

Pure Rust numerics — sovereign, safe, and FFI-free.

KitaSan at COOLJAPAN OÜ
June 20, 2026

↑ Back to all posts