Skip to main content

Crate oxinum_float

Crate oxinum_float 

Source
Expand description

Arbitrary-precision floating-point arithmetic for the OxiNum ecosystem.

Provides wrappers over dashu-float’s FBig/DBig with convenience functions for elementary math: exp, ln, sqrt, pow, trigonometric functions (sin, cos, tan, atan, atan2), hyperbolic functions (sinh, cosh, tanh), and high-precision constants (pi, e, ln2).

Precision-control helpers (precision::with_precision, precision::epsilon, precision::ulp) wrap the underlying dashu-float precision primitives in an ergonomic free-function API.

§Why Hash is not implemented

DBig (FBig<HalfAway, 10>) intentionally does not implement core::hash::Hash. In IEEE 754 (and by extension in essentially every numeric library that takes the standard seriously) floating point values defy the Hash contract: distinct representations can compare equal (e.g. 1.0 and 1.00 at different precisions, or signed zeros +0 and -0), special values like NaN are not equal to themselves, and the canonical form needed to make hashing well-defined varies by use case (totalOrder vs. mathematical equality vs. bitwise identity). Rust’s standard library follows the same convention: f32 and f64 deliberately do not implement Hash. Callers who need a hash key should either use a canonicalised representation (e.g. a tuple of (significand, exponent, precision)) or wrap DBig in a newtype with an explicit, documented hashing policy.

§Features

  • serde (off by default) — enables serde::Serialize / Deserialize for DBig via dashu-float’s own serde feature.

Modules§

native
Native binary-base arbitrary-precision floating-point implementation.
precision
Precision-control helpers for the DBig wrapper.
round
Rounding modes re-exported from dashu-float so callers do not need a direct dependency on dashu-float for basic rounding-mode selection.

Structs§

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.

Enums§

OxiNumError
Errors from OxiNum operations.
RoundingMode
Rounding modes for arbitrary-precision arithmetic.

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.
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.
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.
ln
Compute ln(x) (natural logarithm) with the given precision.
pow
Compute base^exp for arbitrary float exponents.
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).

Type Aliases§

BigFloat
Type alias for decimal big-float.
DBig
Multi-precision float number with decimal exponent and HalfAway rounding mode
OxiNumResult
Convenience alias for Result<T, OxiNumError>.