Parma Polyhedra Library requirements
C++ binary floating-format representations

C++ binary floating-format representations

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
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.

The format model must distinguish field precision from exponent range and retain subnormal scales even when the host has no matching native type.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Check literal metadata for all five descriptors without native arithmetic. Check address-taking and object identity across independent translation units. Check unsigned field widths, configured low/high word order and each smallest-subnormal exponent against independently stated format constants. Check the single-word masks and exhaust all binary16 words against an independent arithmetic extraction of their five exponent bits.

src/Float_defs.hh; src/Float_inlines.hh; tests/float1.cc; tests/floatrepresentationsspec1.cc; tests/constantaddresses1.cc; tests/constantaddresses_aux.cc.

CPP
Internal

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

struct float_ieee754_half;
struct float_ieee754_single;
struct float_ieee754_double;
struct float_ieee754_quad;
struct float_intel_double_extended;
// Each descriptor exposes BASE, EXPONENT_BITS, MANTISSA_BITS,
// EXPONENT_BIAS, EXPONENT_MIN, EXPONENT_MAX,
// EXPONENT_MIN_DENORM and floating_point_format.
SW_SPEC
2
PPL-SPEC-001585
PPL-SPEC-001585
Classification of raw binary floating encodings

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.

Classification must inspect the entire significand, preserving signed zeros and distinguishing low-word NaN payloads from infinity.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Use literal signed zero, subnormal, normal, finite-limit and infinity encodings. Exhaust binary16 encodings and exercise every fraction bit in canonical NaNs of each wider format; verify source-field preservation.

src/Float_defs.hh; src/Float_inlines.hh; tests/float1.cc; tests/floatrepresentationsspec1.cc; tests/constantaddresses1.cc; tests/constantaddresses_aux.cc.

CPP
Internal

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

int inf_sign() const;
int zero_sign() const;
bool is_nan() const;
SW_SPEC
3
PPL-SPEC-001586
PPL-SPEC-001586
Raw floating sign inspection and negation

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.

Sign manipulation is a representation operation and must preserve payload and magnitude information independently of floating arithmetic.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Exhaust signed binary16 bit patterns; check normal, subnormal, zero, infinity and NaN payload cases for every wider binary descriptor. Compare literal unsigned fields after one and two negations.

src/Float_defs.hh; src/Float_inlines.hh; tests/float1.cc; tests/floatrepresentationsspec1.cc; tests/constantaddresses1.cc; tests/constantaddresses_aux.cc.

CPP
Internal

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

bool sign_bit() const;
void negate();
SW_SPEC
4
PPL-SPEC-001587
PPL-SPEC-001587
Adjacent binary floating magnitudes

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.

Directed conversion needs one representable step at boundaries, including subnormal/normal transitions where the Intel integer bit changes.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Check both signs at zero/subnormal, subnormal/normal, significand carry and finite/infinite boundaries. Include cross-word carry/borrow and inverses for all admissible paired magnitudes, with literal field oracles.

src/Float_defs.hh; src/Float_inlines.hh; tests/float1.cc; tests/floatrepresentationsspec1.cc; tests/constantaddresses1.cc; tests/constantaddresses_aux.cc.

CPP
Internal

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

void inc();
void dec();
SW_SPEC
5
PPL-SPEC-001588
PPL-SPEC-001588
Largest finite binary floating magnitude

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.

An inward overflow bound must be finite and must not depend on stale bits in a previously used representation object.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Poison every destination field, request each sign and compare all fields with literal maximum-finite encodings. Check classification and successor to the corresponding infinity.

src/Float_defs.hh; src/Float_inlines.hh; tests/float1.cc; tests/floatrepresentationsspec1.cc; tests/constantaddresses1.cc; tests/constantaddresses_aux.cc.

CPP
Internal

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

void set_max(bool negative);
SW_SPEC
6
PPL-SPEC-001589
PPL-SPEC-001589
Assembly of binary floating fields from an integer significand

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.

Integer-to-field assembly must initialize zero as well as nonzero payloads; GMP export of zero does not write a destination word.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Poison every field and build signed zero, smallest/largest subnormal, least normal, unit, greatest finite and infinity encodings from independent integer bit patterns. Check word-spanning significands in 32- and 64-bit-long builds. For x87 native conversion, check exact subnormal-unit rational bounds on both sides of zero and at the first-subnormal boundary.

src/Float_defs.hh; src/Float_inlines.hh; tests/float1.cc; tests/floatrepresentationsspec1.cc; tests/constantaddresses1.cc; tests/constantaddresses_aux.cc.

CPP
Internal

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

void build(bool negative, mpz_t mantissa, int exponent);