Parma Polyhedra Library requirements
C++ finite scalar sign and ordering
1. Exact scalar sign and ordering PPL-SPEC-000575

For the eleven standard native integer types, mpz_class, canonical finite mpq_class and their admitted checked wrappers, the named comparison functions shall compare the exact mathematical entry values, including operands of different scalar types. Signedness and storage width shall not replace mathematical ordering: a negative signed integer shall be less than every nonnegative unsigned integer, and unbounded integers and rational fractions shall retain their exact values.

cmp(x, y) shall return an int with negative, zero or positive sign exactly when x < y, x = y or x > y. Its nonzero magnitude shall not be prescribed. equal, not_equal, less_than, less_or_equal, greater_than and greater_or_equal shall return true exactly for their named mathematical relations. The corresponding six PPL comparison operators shall have the same meanings when at least one operand is a checked scalar. This operator guarantee shall not alter the built-in operators between two raw native integer types.

sgn(x) shall return exactly -1, 0 or 1 according to the mathematical value's sign. The configured coefficient and raw rational query contracts shall retain 🔗 1. Integral coefficient representation access and sign comparison and 🔗 9. Finite rational sign, comparison and numeric classification. Operands may be the same object. All these queries shall preserve source values, perform no policy result-handler dispatch and require no rounding default. They shall admit every finite representable value allowed by each operand's policy, including ordinary native integer minima and maxima. Checked policies shall provide the backend's relevant classification and representation traits.

Objects shall be live; rational values shall be canonical with positive denominator. Resources shall suffice for exact comparison and temporaries. Callers shall synchronize queries with overlapping object modification and serialize shared numerical temporaries in non-thread-safe builds. These exact scalar queries shall require no library initialization, coefficient constants or FPU rounding setup, and shall preserve hardware direction.

2. Mixed finite floating and exact scalar ordering PPL-SPEC-000576

For one configured supported native floating operand and one exact scalar from 🔗 1. Exact scalar sign and ordering, including their admitted checked wrappers, cmp and the six named comparison predicates shall compare their exact mathematical entry values. The floating value shall mean its exactly stored binary value; a nearby decimal or integral value shall not be substituted. The PPL comparison operators shall have those same relation meanings when at least one operand is checked.

A large integer shall not be rounded to the floating operand's precision before deciding equality or order. Likewise, a finite rational shall retain its numerator/denominator value. Opposite signed floating zeros shall both compare as mathematical zero. Argument order shall not change equality or the mathematical relation: reversing arguments shall reverse strict order. These comparisons shall not invoke policy result handlers or use rounding defaults. Both argument objects shall remain unchanged. Floating/floating ordering shall retain 🔗 4. Ordered comparison of finite native floating-point values.

All operands shall be finite and valid for their selected policies, with canonical positive-denominator rational storage. Exact resources, synchronization and shared-temporary serialization shall follow 🔗 1. Exact scalar sign and ordering. General mixed comparisons shall require upward hardware rounding for their directed conversion filters, and preserve that direction. Native floating conversions and strict result queries shall have the backend/setup prerequisites of 🔗 1. Directed native integral conversion to native floating-point storage and 🔗 4. Directed narrowing between finite native floating-point formats; no coefficient-constant stage shall be required. Available resources shall permit any exact conversion or temporary needed by the comparison.