Skip to main content

oxinum_int/
lib.rs

1#![cfg_attr(oxinum_simd, feature(portable_simd))]
2#![forbid(unsafe_code)]
3//! Arbitrary-precision integer arithmetic for the OxiNum ecosystem.
4//!
5//! Provides `BigInt` and `BigUint` type aliases over `dashu-int`'s `IBig`/`UBig`,
6//! plus number-theory functions: factorial, fibonacci, binomial coefficients,
7//! modular exponentiation, primality testing, and extended GCD.
8
9pub use dashu_int::{IBig, UBig};
10pub use oxinum_core::OxiNumError;
11pub use oxinum_core::OxiNumResult;
12
13// Re-export GCD operation trait so callers can use `.gcd()`.
14pub use dashu_int::ops::Gcd;
15
16// Re-export core traits and types that downstream crates will need.
17pub use oxinum_core::Sign;
18
19/// Type alias: `BigUint` is `dashu_int::UBig`.
20pub type BigUint = UBig;
21
22/// Type alias: `BigInt` is `dashu_int::IBig`.
23pub type BigInt = IBig;
24
25// Sub-modules
26mod number_theory;
27mod traits;
28
29/// Native arbitrary-precision integer types implemented in pure Rust.
30///
31/// This module provides an additive, ground-up native implementation that
32/// coexists with the `dashu`-backed `BigUint`/`BigInt` aliases re-exported
33/// at the crate root. See [`native::BigUint`] for the unsigned core.
34pub mod native;
35
36// Number theory functions
37pub use number_theory::{
38    binomial, extended_gcd, factorial, fibonacci, is_prime, lucas, mod_pow, next_prime,
39};
40
41// Radix conversion and utility functions
42pub use traits::{
43    ibig_abs, ibig_from_radix, ibig_is_one, ibig_is_zero, ibig_signum, ibig_to_radix,
44    ubig_from_radix, ubig_is_one, ubig_is_zero, ubig_to_radix,
45};