Parma Polyhedra Library requirements
C++ extended scalar ordering

C++ extended scalar ordering

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-000920
PPL-SPEC-000920
Infinity ordering and unordered scalar predicates

The named Boolean comparisons in 🔗 1. Exact scalar sign and ordering and 🔗 2. Mixed finite floating and exact scalar ordering shall admit the supported infinity and quiet-NaN representations of their operand types and policies. Minus infinity shall be less than every finite value, which shall be less than plus infinity. Equal-sign infinities shall compare equal; opposite-sign infinities shall compare unequal. Finite values shall retain those existing exact comparison contracts, including mixed storage and signedness.

Whenever either operand is NaN, equal, less_than, less_or_equal, greater_than and greater_or_equal shall return false; not_equal shall return true, including a NaN compared with itself. The corresponding six PPL operators shall have the same meanings when at least one operand is checked. This shall not redefine built-in operators between two raw native values.

For operands that are finite or infinite, cmp shall return a negative, zero or positive int according to that extended ordering. sgn shall return -1 for minus infinity and 1 for plus infinity; finite results shall retain their existing contract. Neither ordered cmp nor sgn shall admit a NaN operand under this contract. No result-handler dispatch or constructor/operator/function rounding default shall be required.

Special representations shall be admitted only under their configured native-format or checked-policy capabilities, following 🔗 1. Native floating-point NaN and infinity predicates, 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 1. Checked special-marker construction and policy assignment. A reserved bit pattern shall retain its finite meaning in another policy that does not reserve it. Native floating sources shall require the corresponding configured support; NaN sources shall be quiet. Finite rational payloads shall remain canonical; admitted rational special payloads shall retain their separate representation contract. Objects may alias the same operand and shall remain live and unchanged throughout the query.

Resource and synchronization prerequisites for finite comparisons shall retain 🔗 1. Exact scalar sign and ordering and 🔗 2. Mixed finite floating and exact scalar ordering. No library/thread initialization, coefficient-constant stage or FPU rounding setup shall be required. Queries shall preserve the hardware rounding direction; floating exception flags shall follow the selected native comparison operations.

Extended domain bounds need mathematical infinity ordering, while NaN must remain unordered rather than acquire an order from its storage encoding.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Use an independent finite/infinity/unordered table across native and checked storage, same and mixed types, both operand orders and self aliases. Check all six predicates/operators, ordered cmp and infinite sgn, advertised special capabilities, different policy interpretations of identical stored patterns, exact return types, no handler/default dependency, unchanged source representations and hardware modes. Cover disabled floating support using the remaining admitted integral/GMP scope.

src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; src/checked_ext_inlines.hh; src/checked_inlines.hh; src/checked_float_inlines.hh; tests/extendedorderingspec1.cc; tests/numericpublic1.cc.

CPP
Public

Public header: <ppl.hh>; effective PPL instantiations for the admitted raw or checked scalar types X and Y:

bool equal(const X& x, const Y& y);
bool not_equal(const X& x, const Y& y);
bool less_than(const X& x, const Y& y);
bool less_or_equal(const X& x, const Y& y);
bool greater_than(const X& x, const Y& y);
bool greater_or_equal(const X& x, const Y& y);
int cmp(const X& x, const Y& y);  // Non-NaN operands.
int sgn(const X& x);             // Non-NaN operand.

The operators ==, !=, <, <=, > and >= shall be admitted when at least one argument is checked.