Skip to main content

Crate oxinum

Crate oxinum 

Source
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:

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 dashu backend).
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 decimal DBig.
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.
ParseNumberError
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§

OxiNumError
Errors from OxiNum operations.
ParsedNumber
The result of parsing a numeric string with parse.
RoundingMode
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 identity atan(x) = pi/2 - atan(1/x).
atan2
Compute atan2(y, x) with proper quadrant handling.
best_rational_approximation
Find the best rational approximation to x with denominator at most max_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^x with the given number of significant decimal digits.
extended_gcd
Computes the extended GCD of a and b, returning (gcd, x, y) such that a * x + b * y = gcd.
factorial
Computes n! (factorial of n).
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 n is (probably) prime using the Miller-Rabin test.
ln
Compute ln(x) (natural logarithm) with the given precision.
lucas
Computes the Lucas number L(n) where L(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) where whole is the integer part (toward zero) and fractional is the remaining proper fraction with the same sign.
mod_pow
Computes (base^exp) mod modulus using 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^exp for 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 an IBig.
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 x with 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_places digits after the point (truncated, not rounded).
version
Returns the version of the oxinum crate.

Type Aliases§

BigFloat
Type alias for decimal big-float.
BigInt
Type alias: BigInt is dashu_int::IBig.
BigRational
Type alias for clarity.
BigUint
Type alias: BigUint is dashu_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.
OxiNumResult
Convenience alias for Result<T, OxiNumError>.
Rational
Arbitrary-precision exact rational number.