Skip to main content

Module mp_float

Module mp_float 

Source
Expand description

MpFloat / MpComplex adapter types that mirror the rug::Float / rug::Complex API. Drop-in replacements for rug-using code. MpFloat — a rug::Float-compatible adapter over dashu-float’s DBig.

This module provides MpFloat and MpComplex as drop-in replacements for the rug::Float and rug::Complex types used in scirs2-special’s arbitrary_precision module. The API surface matches what that module actually calls; it is not a complete re-implementation of the rug API.

§Design

MpFloat wraps dashu-float’s DBig (decimal arbitrary-precision big-float) and delegates all arithmetic to it. Special functions (gamma, erf, etc.) delegate to crate::special.

§Precision

rug::Float precision is measured in binary bits. DBig precision is in decimal digits. The conversion used here is: decimal_digits = ceil(bits * log10(2))bits * 0.30103 plus a 5-digit guard margin, with a minimum of 10 decimal digits.

Structs§

MpComplex
Arbitrary-precision complex number.
MpFloat
Arbitrary-precision floating-point number.

Enums§

Round
Rounding modes for arbitrary-precision operations.

Traits§

MpPow
Pow implementation for MpFloatbase.pow(exp).

Functions§

bits_to_decimal_prec
Convert a bit precision to an approximate decimal digit count.
catalan_at_bits
Build Catalan’s constant at the given bit precision.
euler_gamma_at_bits
Build a DBig constant for the Euler-Mascheroni constant at the given bit precision. Convenience wrapper so PrecisionContext doesn’t need to import special module.