oxinum_float/native/mod.rs
1//! Native arbitrary-precision floating-point implementation.
2//!
3//! This module provides [`BigFloat`], a binary-base (`b = 2`) arbitrary
4//! precision floating-point number with explicit precision tracking and
5//! post-operation rounding. It is implemented in pure safe Rust on top of
6//! the native [`oxinum_int::native::BigUint`] limb-vector integer.
7//!
8//! The wrapper-level [`crate::BigFloat`] alias (decimal-base `DBig` via
9//! `dashu-float`) is a separate type — they coexist intentionally. Reach
10//! for the native `BigFloat` when you need ground-up Pure Rust binary
11//! arithmetic with explicit rounding-mode control.
12//!
13//! # Phase 2 scope (this module)
14//!
15//! - Construction / decomposition: `zero`, `nan`, `infinity`, `neg_infinity`,
16//! `from_i64`, `from_f64`, `to_f64`, `from_parts`, `with_precision`,
17//! `round_to_precision`.
18//! - Accessors: `precision`, `sign`, `mantissa`, `exponent`, `is_zero`,
19//! `is_finite`, `is_infinite`, `is_nan`, `is_normal`, `classify`,
20//! `is_sign_positive`, `is_sign_negative`, `signum`, `abs`, `neg`.
21//! - Classification: `FloatClass` enum (`Finite`, `Infinite`, `Nan`).
22//! - Arithmetic: `Add`, `Sub`, `Neg`, plus the `*Assign` variants.
23//! - Comparison: `PartialOrd`, `PartialEq` (precision-independent, NaN-aware).
24//! **Note:** `Ord` and `Eq` are *not* implemented — NaN breaks reflexivity
25//! and totality. Use `BigFloat::total_cmp` for a sort-stable total order.
26//! - Display: hex-float-like `0xb<binary>p<exponent>`, `NaN`, `inf`, `-inf`.
27//!
28//! Multiplication, division, and square root land in `float_mul`,
29//! `float_div`, and `float_sqrt`. They feed back through
30//! [`BigFloat::from_parts`] so the canonical-form invariants are uniformly
31//! enforced.
32//!
33//! # Examples
34//!
35//! ```
36//! use oxinum_float::native::{BigFloat, RoundingMode};
37//!
38//! let one = BigFloat::from_i64(1, 32, RoundingMode::HalfEven);
39//! let two = BigFloat::from_i64(2, 32, RoundingMode::HalfEven);
40//! let sum = &one + &two;
41//! assert_eq!(sum.to_f64(), 3.0);
42//!
43//! let three = BigFloat::from_i64(3, 32, RoundingMode::HalfEven);
44//! let six = &two * &three;
45//! assert_eq!(six.to_f64(), 6.0);
46//! ```
47
48mod atan;
49pub mod binary_splitting;
50mod constants;
51mod context;
52mod core_traits;
53mod float;
54mod float_add;
55mod float_convert;
56mod float_div;
57mod float_exp;
58mod float_ln;
59mod float_mul;
60mod float_sqrt;
61mod format_ext;
62mod ln_agm;
63pub mod nonfinite;
64mod pow;
65mod trig;
66
67#[cfg(feature = "num-traits")]
68mod num_traits_impl;
69
70#[cfg(feature = "serde")]
71mod serde_impl;
72
73pub use constants::{e_const, ln2, pi};
74pub use context::FloatContext;
75pub use float::{BigFloat, FloatClass, RoundingMode};
76
77#[cfg(feature = "num-traits")]
78pub use num_traits_impl::ParseBigFloatError;