Expand description
§OxiNum
OxiNum is the COOLJAPAN Pure-Rust arbitrary-precision math layer
(GMP/MPFR-free). It provides arbitrary-precision integers, floats, and
rationals, plus number-theory and elementary functions, built on the
Pure Rust dashu backend.
§Dual exposure: dashu-backed (default) and pure-native (native::)
Two coexistent type families are intentionally exposed:
- The crate-root re-exports —
Int,Natural,Float,Rational,Complex,BigInt,BigUint,DBig,RBig,CBig, … — are the dashu-backed default and remain the recommended entry point for application code today. nativere-exports the ground-up Pure Rust types (native::BigUint,native::BigInt,native::BigFloat,native::BigRational,native::BigComplex) implemented inoxinum-int,oxinum-float,oxinum-rational, andoxinum-complex. Reach for these when you want zerodashudependence, explicit limb / rounding-mode control, or to migrate incrementally toward the eventual native default. Use the parallel aliasesnative::Int,native::Natural,native::Float,native::Rational, andnative::Complexto mirror the top-level shape.
No type at the crate root is shadowed — the namespaces are disjoint, so existing code keeps compiling unchanged.
§Quick start
use oxinum::prelude::*;
// Arbitrary-precision integer arithmetic
let big = factorial(20);
assert_eq!(big.to_string(), "2432902008176640000");
// High-precision pi
let pi = constants::pi(50);
assert!(pi.to_string().starts_with("3.14159265358979"));Modules§
- constants
- Mathematical constants at arbitrary precision.
- convert
- Cross-type conversions between OxiNum numeric types.
- native
- Pure-native arbitrary-precision types and helpers (no
dashubackend). - prelude
- Common types and functions for glob import.
- round
- Rounding modes for arbitrary-precision floating-point operations.
Structs§
- CBig
- Arbitrary-precision complex number
re + im·i, with each component a decimalDBig. - Context
- The context containing runtime information for the floating point number and its operations.
- FBig
- An arbitrary precision floating point number with arbitrary base and rounding mode.
- IBig
- An signed arbitrary precision integer.
- Parse
Number Error - Rich parse-error diagnostic carrying the offending message together with the 1-based line and column where the parser stopped.
- RBig
- An arbitrary precision rational number.
- Relaxed
- An arbitrary precision rational number without strict reduction.
- UBig
- An unsigned arbitrary precision integer.
Enums§
- OxiNum
Error - Errors from OxiNum operations.
- Parsed
Number - The result of parsing a numeric string with
parse. - Rounding
Mode - Rounding modes for arbitrary-precision arithmetic.
- Sign
- An enum representing the sign of a number
Traits§
- Gcd
- Compute the greatest common divisor.
Functions§
- atan
- Compute
atan(x)using dashu-float’s binary conversion and Taylor approach internally. For |x| <= 0.5 we use the series directly; for larger |x| <= 1 we use the half-angle formula; for |x| > 1 we use the identityatan(x) = pi/2 - atan(1/x). - atan2
- Compute
atan2(y, x)with proper quadrant handling. - best_
rational_ approximation - Find the best rational approximation to
xwith denominator at mostmax_denom. - binomial
- Computes the binomial coefficient
C(n, k) = n! / (k! * (n-k)!). - compute_
e - Compute Euler’s number e to the given number of decimal digits.
- compute_
ln2 - Compute ln(2) to the given number of decimal digits.
- compute_
pi - Compute pi to the given number of decimal digits of precision.
- continued_
fraction - Compute the continued fraction expansion of a rational number.
- cos
- Compute
cos(x)using Taylor series with argument reduction. - cosh
- Compute
cosh(x) = (e^x + e^(-x)) / 2. - exp
- Compute
e^xwith the given number of significant decimal digits. - extended_
gcd - Computes the extended GCD of
aandb, returning(gcd, x, y)such thata * x + b * y = gcd. - factorial
- Computes
n!(factorial ofn). - fibonacci
- Computes the
n-th Fibonacci number using the fast-doubling method. - from_
continued_ fraction - Reconstruct a rational number from its continued fraction coefficients.
- is_
prime - Tests whether
nis (probably) prime using the Miller-Rabin test. - ln
- Compute
ln(x)(natural logarithm) with the given precision. - lucas
- Computes the Lucas number
L(n)whereL(0) = 2, L(1) = 1. - mediant
- Compute the mediant of two rationals:
(a_num + b_num) / (a_den + b_den). - mixed_
number - Decompose a rational into a mixed number:
(whole, fractional)wherewholeis the integer part (toward zero) andfractionalis the remaining proper fraction with the same sign. - mod_pow
- Computes
(base^exp) mod modulususing binary (right-to-left) exponentiation. - next_
prime - Returns the smallest prime greater than
n. - parse
- Parse a numeric string, auto-detecting integer, rational, or float format.
- pow
- Compute
base^expfor arbitrary float exponents. - rational_
abs - Returns the absolute value of
x. - rational_
ceil - Returns the smallest integer not less than
x(toward positive infinity). - rational_
floor - Returns the largest integer not greater than
x(toward negative infinity). - rational_
pow - Raise a rational to an integer power.
- rational_
reciprocal - Returns the reciprocal
1/x. - rational_
round - Returns the nearest integer to
x(ties away from zero). - rational_
signum - Returns the sign of
x: -1, 0, or +1 as anIBig. - rational_
truncate - Returns the integer part of
x(truncated toward zero). - sin
- Compute
sin(x)using Taylor series with argument reduction. - sinh
- Compute
sinh(x) = (e^x - e^(-x)) / 2. - sqrt
- Compute the square root of
xwith the given precision. - tan
- Compute
tan(x) = sin(x) / cos(x). - tanh
- Compute
tanh(x) = sinh(x) / cosh(x). - to_
decimal_ string - Convert a rational to a decimal string with
decimal_placesdigits after the point (truncated, not rounded). - version
- Returns the version of the
oxinumcrate.
Type Aliases§
- BigFloat
- Type alias for decimal big-float.
- BigInt
- Type alias:
BigIntisdashu_int::IBig. - BigRational
- Type alias for clarity.
- BigUint
- Type alias:
BigUintisdashu_int::UBig. - Complex
- Arbitrary-precision complex number (decimal-backed,
re + im·i). - DBig
- Multi-precision float number with decimal exponent and HalfAway rounding mode
- Float
- Arbitrary-precision decimal floating-point number.
- Int
- Arbitrary-precision signed integer.
- Natural
- Arbitrary-precision unsigned integer.
- OxiNum
Result - Convenience alias for
Result<T, OxiNumError>. - Rational
- Arbitrary-precision exact rational number.