Parma Polyhedra Library requirements
C++ scalar extraction into configured coefficient components
PPL-SPEC-000919
1. Exact scalar numerator and denominator extraction UID: PPL-SPEC-000919 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

For a finite native integer, mpz_class, supported native floating value, or admitted Checked_Number scalar, numer_denom(from, numer, denom) shall obtain the source's exact rational value n ⁄ d in canonical form and assign n to numer followed by positive d to denom. The components shall be coprime. An integral source shall give its exact integer and denominator one; either sign of native zero shall give zero and one. Native floating values shall be interpreted as their exact binary values. Raw mpq_class extraction shall remain governed by 🔗 8. Rational canonical-form inspection and coefficient component extraction; a checked rational source here shall have a finite canonical payload under 🔗 1. Exact rational assignment from rational and integral sources. Supported floating-source availability and conversion prerequisites shall follow 🔗 2. Exact rational assignment of finite native floating-point values.

The output coefficient objects shall be distinct. When types permit, one output may designate the complete integral source value, including the whole integral raw value owned by a checked source. Both outputs shall then use the source's entry value, copied before either assignment. Outputs shall not designate proper numerator/denominator subobjects of rational source storage. A source disjoint from the output objects shall remain unchanged, including its floating sign of zero and rational component representation.

Both components shall fit the configured coefficient range for an unchecked bounded coefficient profile. A checked bounded profile shall report unrepresentable components through the configured coefficient assignment policy and its std::overflow_error in 🔗 5. Checked coefficient overflow and result-policy dispatch. A failure assigning the denominator may follow a completed numerator assignment; there shall be no two-output rollback promise. Surviving outputs shall retain that assignment's valid-reuse and destruction guarantees. Unbounded coefficient storage shall impose no fixed component range. Allocation and other escaping exceptions shall retain the underlying operations' guarantees.

The helper shall return void. It shall not require rounding defaults or a handler from a checked source policy, or invoke that source policy's handler. Assignment to the configured coefficient outputs shall retain their own policy behavior. Objects and borrowed source values shall remain live; access shall be synchronized against overlapping modification. With a non-thread-safe build, callers shall serialize operations using shared PPL temporary storage; a thread-safe build shall provide independent per-thread temporaries. No library/thread initialization or coefficient- constant stage shall be required. Available resources shall limit temporary rational storage. The current hardware rounding direction shall be preserved.

RATIONALE:

Constructing exact constraints from scalar values requires canonical integer components without first rounding the value to a configured coefficient.

INTERFACE:

Internal header: math_utilities_defs.hh; function template in Parma_Polyhedra_Library, for the source families above:

template <Native_Or_Checked_Number T>
void
numer_denom(const T& from, Coefficient& numer, Coefficient& denom);
VERIFICATION_CRITERIA:

Check literal integral/GMP components and independent binary-significand floating oracles, both signs and signed zeros, canonical rational wrappers, source-policy capability without defaults/handlers and exact void return. Exercise actual coefficient ranges, first- and second-output checked overflow, valid reuse, borrowed integral source aliases and independent outputs. Verify source representation and hardware-mode preservation; cover actual disabled floating support without instantiating unavailable source conversions.

SOURCE:

src/math_utilities_defs.hh; src/math_utilities_inlines.hh; tests/scalarcomponentsspec1.cc.