Parma Polyhedra Library requirements
C++ binary floating-format representations
1. Binary floating-format fields and numerical metadata PPL-SPEC-001584

The binary representation descriptors shall expose unsigned storage fields and metadata for IEEE binary16, binary32, binary64 and binary128, and Intel 80-bit double-extended format. Their radix shall be two. Exponent-field width, fraction width and bias shall respectively be (5, 10, 15), (8, 23, 127), (11, 52, 1023), (15, 112, 16383) and (15, 63, 16383). The Intel format shall store its integer bit explicitly; the IEEE normal formats shall use an implicit leading one.

The metadata members shall be immutable constant expressions with inline definitions. Taking their addresses in independent translation units shall refer to the same objects.

EXPONENT_MAX shall equal the bias, EXPONENT_MIN shall be one minus the bias, and EXPONENT_MIN_DENORM shall be EXPONENT_MIN minus the fraction width. The smallest positive subnormal shall consequently be 2 EXPONENT_MIN_DENORM. The format enumeration shall identify the corresponding descriptor. Single-word descriptors shall expose word; multiword descriptors shall expose msp and lsp, with their layout selected by the configured word order. Intel sign and exponent shall occupy the low 16 bits of msp; padding shall not be a numerical field.

For the binary16 and binary32 single-word descriptors, SGN_MASK shall select only the sign bit and EXP_MASK shall select only the exponent field. Their respective mask pairs shall be (0x8000,0x7c00) and (0x80000000,0x7f800000). Masking shall exclude all fraction bits and exponent masking shall be independent of sign.

Raw descriptor operations shall use unsigned fields and GMP integer storage. They shall be usable independently of native hardware availability of that floating format and shall require no FPU rounding-state setup. Callers shall provide live objects and valid initialized fields before inspection, plus synchronization for overlapping access. These binary descriptor rules shall not extend to the hexadecimal descriptor types.

PPL-SPEC-001585
2. Classification of raw binary floating encodings PPL-SPEC-001585

For initialized IEEE descriptor fields, inf_sign shall return minus one for negative infinity, plus one for positive infinity and zero otherwise. zero_sign shall similarly distinguish negative zero and positive zero, returning zero for every other encoding. is_nan shall be true exactly when all exponent bits are one and at least one fraction bit is nonzero. Sign shall not affect NaN recognition. Every fraction bit, including bits in either stored word, shall distinguish a NaN from infinity.

The same results shall hold for canonical Intel encodings: infinity shall have an all-ones exponent and exactly the explicit integer bit in its significand; a canonical NaN shall have an all-ones exponent, the integer bit set and a nonzero fraction. Canonical finite normal encodings shall have the integer bit set, and subnormal/zero encodings an exponent and integer bit of zero. Other Intel encodings shall not be admitted by this classification contract. Padding bits of msp shall not affect Intel classification. Inputs shall remain unchanged and the conditions of 🔗 1. Binary floating-format fields and numerical metadata shall apply.

PPL-SPEC-001586
3. Raw floating sign inspection and negation PPL-SPEC-001586

sign_bit shall return the stored sign bit. negate shall toggle exactly that bit, preserving exponent, significand and other stored bits. Two negations shall restore every field, including zero, infinity and NaN payloads. Sign inspection shall preserve every field. The descriptor and lifetime conditions of 🔗 1. Binary floating-format fields and numerical metadata shall apply.

PPL-SPEC-001587
4. Adjacent binary floating magnitudes PPL-SPEC-001587

For canonical binary encodings, inc shall replace a finite magnitude with its immediately succeeding representable magnitude, retaining sign; dec shall replace a nonzero finite or infinite magnitude with its immediately preceding representable magnitude, retaining sign. Thus increment of either signed zero shall produce the same-sign smallest subnormal; decrement of the smallest subnormal shall produce the same-sign zero. The largest finite magnitude shall increment to infinity, whose decrement shall recover that finite magnitude. Calls shall exclude NaNs, decrement of zero and increment of infinity.

Carries and borrows shall cross stored-word boundaries. Intel transitions between the largest subnormal and least normal shall clear or set the explicit integer bit as required for a canonical encoding. The conditions of 🔗 1. Binary floating-format fields and numerical metadata shall apply. Numerical ordering of negative operands shall follow the preserved sign and changed magnitude.

PPL-SPEC-001588
5. Largest finite binary floating magnitude PPL-SPEC-001588

set_max(negative) shall overwrite the descriptor with the largest finite magnitude and the requested sign. IEEE encodings shall use the largest finite exponent field and all fraction bits one; Intel encoding shall also set its explicit integer bit. Prior field values shall not influence the result. The value shall classify as finite, nonzero and of the requested sign. The conditions of 🔗 1. Binary floating-format fields and numerical metadata shall apply.

PPL-SPEC-001589
6. Assembly of binary floating fields from an integer significand PPL-SPEC-001589

build(negative,mantissa,exponent) shall overwrite every numerical field with the requested sign, biased exponent and significand. For IEEE formats with fraction width f, the stored fraction shall be the remainder of m on division by 2f, where m is the integer mantissa on entry; its possible leading normal bit shall be implicit. Intel storage shall contain all 64 significand bits, including its explicit integer bit. The stored exponent shall be exponent + EXPONENT_BIAS. A zero mantissa and zero biased exponent shall produce the requested signed zero, independently of prior destination bits and host unsigned long width. The Intel builder shall clear nonnumerical high msp bits.

Callers shall provide a live GMP integer mantissa with 0 ≤ m < 2f + 1 for IEEE formats or 0 ≤ m < 264 for Intel, and an exponent whose biased value lies within the exponent field. Mantissa and destination storage shall be disjoint. This shall assemble fields without numerical rounding or normalization; callers needing a canonical finite or special encoding shall provide compatible fields. The mantissa shall be mutable workspace: its numerical value after the call need not equal its entry value, but it shall remain a valid GMP integer. The conditions of 🔗 1. Binary floating-format fields and numerical metadata shall apply.