Expand description
Exact rational arithmetic for the OxiNum ecosystem.
Provides RBig and Relaxed re-exports from dashu-ratio, plus
additional functions: continued fraction expansion, best rational
approximation, decimal string conversion, mediant, mixed number
representation, and floor/ceil/round/truncate operations.
Modules§
- native
- Native arbitrary-precision rational implementation built on
oxinum_int::native::BigInt/oxinum_int::native::BigUint.
Structs§
- IBig
- An signed arbitrary precision integer.
- Mixed
Number - Newtype wrapper providing
FromStrfor the mixed-number format. - 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.
Functions§
- best_
rational_ approximation - Find the best rational approximation to
xwith denominator at mostmax_denom. - continued_
fraction - Compute the continued fraction expansion of a rational number.
- farey_
sequence - Generate the order-
nFarey sequenceF_n. - from_
continued_ fraction - Reconstruct a rational number from its continued fraction coefficients.
- from_
f32 - Convert an
f32to an exact rational. - from_
f64 - Convert an
f64to an exact rational. - from_
stern_ brocot_ path - Reconstruct a positive rational from its Stern-Brocot path.
- 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. - parse_
mixed - Parse a mixed-number string.
- 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_
from_ integer - Construct an
RBigfrom an integer value. - rational_
is_ integer - Returns
trueiffxrepresents an integer (i.e. its reduced denominator is one). - 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_
to_ integer - Extract the integer value of
xif it is one. - rational_
truncate - Returns the integer part of
x(truncated toward zero). - stern_
brocot_ path - Compute the Stern-Brocot path encoding for a positive rational.
- to_
decimal_ string - Convert a rational to a decimal string with
decimal_placesdigits after the point (truncated, not rounded). - to_f64
- Convert a rational to the nearest
f64(round-to-nearest, ties-to-even). - to_
f64_ exact - Convert a rational to an
f64, requiring exact representability.
Type Aliases§
- BigRational
- Type alias for clarity.
- OxiNum
Result - Convenience alias for
Result<T, OxiNumError>.