Parma Polyhedra Library requirements
C++ finite native floating-point unary operations and ordering
1. Finite native floating-point floor, ceiling and truncation UID: PPL-SPEC-000325 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP, NATIVE_FP_AVAILABLE VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

The source and destination shall have admitted raw or checked types in 🔗 1. Native floating-point NaN and infinity predicates with the same native storage format F. The source shall be finite, with exact represented value a. floor_assign_r shall assign ⌊a⌋; ceil_assign_r shall assign ⌈a⌉; and trunc_assign_r shall assign trunc(a) toward zero. Each result shall be exactly representable in F and shall return V_EQ for all four base directions in 🔗 4. Rounding-direction intent, composition and inspection, with or without the strict-relation flag. This exact relation shall describe the specified integer-valued function, even when its value differs from the source. When a result is zero, it shall have the source's sign.

A nonintegral source shall require the current hardware rounding direction to be upward. An integral source shall require no particular current hardware direction. Calls shall preserve that direction. A source may be the destination itself or designate its raw storage; the result shall be computed from the source's entry value. Source and destination may also share storage through a checked object's raw-value reference. A source with distinct storage shall remain unchanged. The destination shall be live and assignable. Object synchronization, availability, initialization independence and nontrapping floating-point conditions shall follow 🔗 1. Native floating-point NaN and infinity predicates. The _r interfaces shall return the result without policy-handler dispatch.

RATIONALE:

Rounding a finite binary value to an integer-valued value in the same format has an exact mathematical result. Hardware prerequisites and signed-zero behavior remain part of the callable interface.

INTERFACE:

Public header: <ppl.hh>; effective template instantiations for admitted To and From with the same native storage format:

Result floor_assign_r(To& to, const From& from, Rounding_Dir dir);
Result ceil_assign_r(To& to, const From& from, Rounding_Dir dir);
Result trunc_assign_r(To& to, const From& from, Rounding_Dir dir);
VERIFICATION_CRITERIA:

Use exact significand/power-of-two rational oracles for positive and negative fractions, halves, signed zeros, subnormals, precision boundaries and finite maxima. Check every admitted source/destination policy combination, all direction/strict requests, same-object and raw-storage aliases, zero signs and preserved sources. Use upward hardware mode for nonintegral inputs and every hardware mode for integral inputs.

SOURCE:

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingunaryspec1.cc.

2. Exact finite native floating-point negation and absolute value UID: PPL-SPEC-000326 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP, NATIVE_FP_AVAILABLE VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For the same-format admitted raw or checked source/destination types in 🔗 1. Finite native floating-point floor, ceiling and truncation and a finite source with represented value a, neg_assign_r shall assign  − a and abs_assign_r shall assign |a|. Both shall return V_EQ under all four base directions, with or without ROUND_STRICT_RELATION. Negation shall reverse a zero's sign. Absolute value shall produce positive zero for either signed zero. All finite extrema and subnormals shall retain their exact magnitudes, independent of the configured global coefficient range.

No particular current hardware rounding direction shall be required, and calls shall preserve that direction. Destination validity, source aliases, source preservation, synchronization, availability, initialization independence and floating-point exception conditions shall follow 🔗 1. Finite native floating-point floor, ceiling and truncation. The _r interfaces shall return their result without policy-handler dispatch.

RATIONALE:

A native floating-point sign change and magnitude extraction need no bounded coefficient intermediate and introduce no approximation for finite operands.

INTERFACE:

Public header: <ppl.hh>; effective template instantiations for admitted To and From with the same native storage format:

Result neg_assign_r(To& to, const From& from, Rounding_Dir dir);
Result abs_assign_r(To& to, const From& from, Rounding_Dir dir);
VERIFICATION_CRITERIA:

For every configured format and admitted source/destination policy combination, compare exact dyadic values and sign bits at signed zeros, subnormals, ordinary values and finite extrema. Check all direction/strict requests, all hardware modes, self/raw-storage aliases and distinct-source preservation.

SOURCE:

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingunaryspec1.cc.

PPL-SPEC-000327
3. Sign of a finite native floating-point value UID: PPL-SPEC-000327 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP, NATIVE_FP_AVAILABLE VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For an admitted raw or checked source type in 🔗 1. Native floating-point NaN and infinity predicates whose represented value a is finite, sgn(x) shall return  − 1 when a < 0, zero when a = 0 and 1 when a > 0. Both signed zeros shall return zero. A negative subnormal shall remain negative and a positive subnormal positive.

Source validity, preservation, synchronization, availability, initialization independence and floating-point state conditions shall follow 🔗 1. Native floating-point NaN and infinity predicates. The result shall require no arithmetic in the configured coefficient type and shall be independent of hardware direction.

RATIONALE:

A complete sign query must distinguish zero from nonzero native values at every scale without imposing an unrelated coefficient-width limit.

INTERFACE:

Public header: <ppl.hh>; effective template instantiation for admitted From:

int sgn(const From& x);
VERIFICATION_CRITERIA:

Check signed zeros, both signs of subnormal/normal values, precision boundaries and finite extrema for raw and all admitted checked types. Compare with the exact rational sign under every hardware mode, preserving the source and direction.

SOURCE:

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingunaryspec1.cc.

4. Ordered comparison of finite native floating-point values UID: PPL-SPEC-000328 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP, NATIVE_FP_AVAILABLE VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For admitted raw or checked operand types in 🔗 1. Native floating-point NaN and infinity predicates with the same native storage format and finite represented values a and b, cmp(x, y) shall return a negative integer exactly when a < b, zero exactly when a = b and a positive integer exactly when a > b.

equal, not_equal, less_than, less_or_equal, greater_than and greater_or_equal shall return the truth values of a = b, a ≠ b, a < b, a ≤ b, a > b and a ≥ b, respectively. The corresponding PPL operators ==, !=, <, <=, > and >= shall return those same truth values when at least one operand is checked. Oppositely signed zeros shall compare equal. The operands may designate the same object or raw storage.

Both operand objects shall remain unchanged. Source validity, synchronization, availability, initialization independence and floating-point state conditions shall follow 🔗 1. Native floating-point NaN and infinity predicates. Comparison shall require no bounded coefficient intermediate and no particular hardware rounding direction, and shall preserve that direction.

RATIONALE:

Clients need a total ordering for finite represented values that treats signed zeros equally and preserves distinctions between adjacent nonzero values.

INTERFACE:

Public header: <ppl.hh>; effective template instantiations for admitted Left and Right with the same native storage format:

int cmp(const Left& x, const Right& y);
bool equal(const Left& x, const Right& y);
bool not_equal(const Left& x, const Right& y);
bool less_than(const Left& x, const Right& y);
bool less_or_equal(const Left& x, const Right& y);
bool greater_than(const Left& x, const Right& y);
bool greater_or_equal(const Left& x, const Right& y);

The six comparison operators shall be available when at least one operand is Checked_Number.

VERIFICATION_CRITERIA:

Cross every admitted same-format operand-policy combination and compare ordered pairs against exact rational oracles. Include equal/self-aliased operands, oppositely signed zeros, adjacent values, subnormals, finite extrema and mixed signs. Check cmp sign, all six named predicates and every available checked comparison operator under all hardware modes, preserving both sources.

SOURCE:

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingunaryspec1.cc.