Initialization, assignment, and conversion

Read side by side

On this page

This layer makes the independent floating representation usable without first constructing an MPFR object. All ordinary calculations terminate in ppf_t and use the independent rounding, range, and flag machinery.

Initialization

The library supports explicit precision, thread-local default precision, variadic initialization, variadic clearing, precision changes, and exact structure swaps. Every initialized object owns its allocation and remains valid independently of the context that created it.

Assignment

Assignment is available from:

Rational and text inputs are represented exactly as an integer numerator and positive integer denominator before the one final binary rounding decision. The parser supports leading space, an optional sign, binary and hexadecimal prefixes under base detection, radix points, base exponents, binary exponents for bases 2 and 16, infinities, signed NaNs, and partial parsing through an end pointer.

Conversion

The implemented outputs are:

The GMP floating conversion deserves special treatment. A GNU mpf_t has an integer number of significand limbs, but its usable binary precision depends on its exponent alignment. The conversion rounds first to that effective precision and writes the aligned limbs directly. This avoids retaining an unintended guard limb and reproduces the MPFR ternary result.

Portable scope

The portable layer covers every nonconditional initialization, assignment, combined-initialization, conversion, and fit-test entry in the MPFR inventory. The binary128, decimal64, and decimal128 interfaces are conditional on compiler and library support and are not enabled in the baseline build.