Parma Polyhedra Library requirements
C++ finite native floating quotient and residues
1. Truncated native floating quotient before storage rounding PPL-SPEC-000506

The source and destination types shall be the admitted same-format native or Checked_Number<F, Check_Overflow_Policy<F>> types in 🔗 4. Rounding, result classes and state for finite native binary arithmetic. Both sources shall be finite, with represented values a and b, and b ≠ 0. Let n = trunc(a ⁄ b), where truncation is toward zero in exact real arithmetic. idiv_assign_r shall round and store n in F; it shall not substitute truncation of an already rounded real quotient.

ROUND_DOWN shall select the greatest representable value not exceeding n; ROUND_UP shall select the least representable value not less than n, with admitted infinite endpoints as in 🔗 5. Floating conversion overflow thresholds and computed-value classes. For n in the finite native range, ROUND_IGNORE shall round n toward zero, independently of the caller's hardware direction. Outside that range, it shall follow the explicit delegated overflow value-selection rules in 🔗 5. Floating conversion overflow thresholds and computed-value classes, including their signed infinite endpoints. ROUND_NOT_NEEDED shall require n to be finite and exactly representable in F. Adding ROUND_STRICT_RELATION shall retain the same value-selection rules. For a finite result, the returned relation shall be V_EQ, V_GT or V_LT according as n is equal to, greater than or less than the stored value. Infinite endpoints shall carry their actual result class and relation: positive infinity shall return V_LT_PLUS_INFINITY and negative infinity shall return V_GT_MINUS_INFINITY, also for nonstrict requests. A zero result shall have the exclusive-or of the source signs.

The native hardware direction shall be upward, except that an exactly representable integral real quotient a ⁄ b shall require no particular hardware direction. The operation shall preserve the hardware direction. Native backend setup, live-object and source/destination alias rules, exception conditions and initialization independence shall follow 🔗 4. Rounding, result classes and state for finite native binary arithmetic. The operands may alias each other. Distinct source objects shall remain unchanged. Resources for exact integer/rational temporaries shall be available, and their temporary pools shall be serialized in a build without thread-safe support. Neither the configured coefficient range nor irrational-precision settings shall restrict the quotient.

2. Exact truncating remainder of finite native floating values PPL-SPEC-000507

For the finite same-format source/destination types and nonzero divisor in 🔗 1. Truncated native floating quotient before storage rounding, rem_assign_r shall assign exactly r = a − trunc(a ⁄ b)b. It shall satisfy |r| < |b|; a nonzero remainder shall have the sign of a and a zero remainder shall retain the first source's sign. The reconstruction identity shall use the mathematical truncated quotient, even when that integer is not exactly representable in F.

All four valid rounding directions, with or without ROUND_STRICT_RELATION, shall return V_EQ and the same exact value. No particular hardware direction or inexact-flag support shall be required; the hardware direction shall remain unchanged. Native backend availability, object validity, source/destination and source/source aliases, source preservation, initialization independence and exception conditions shall follow 🔗 1. Truncated native floating quotient before storage rounding, without its upward-direction or exact-temporary resource prerequisites. No irrational-precision setting or coefficient range shall affect the remainder.

3. Exact centered native residue modulo a power of two PPL-SPEC-000508

The source/destination types shall be as in 🔗 1. Finite native addition and subtraction of a power of two, with finite source value a and an admitted exponent e; let m = 2e. smod_2exp_assign_r shall assign the unique value s ∈ [ − m ⁄ 2, m ⁄ 2) congruent to a modulo an integer multiple of m. This residue shall be exactly representable in F. If it is zero, its native sign shall equal the source's sign. In particular the positive half-modulus shall map to the negative half-modulus.

The result shall be V_EQ for every valid rounding request, including ordinary, strict and exactness requests. This exact relation shall not depend on native inexact-information availability or preexisting exception flags. The truncating remainder is exact, and either centering correction subtracts two representable magnitudes within a factor of two. Thus cancellation is exact and no rounded arithmetic protocol or inexact-status query is needed.

No particular hardware direction shall be required for these exact calculations. The operation shall preserve the hardware direction. Native backend setup, object validity, synchronization, destination/source aliases, source preservation, initialization independence and floating-point exception conditions shall follow 🔗 4. Rounding, result classes and state for finite native binary arithmetic. No bounded coefficient intermediate or irrational-precision setting shall limit the result.

4. Rounded nonnegative native residue modulo a power of two PPL-SPEC-000509

For the source/destination types, finite source value a and admitted power-of-two modulus m in 🔗 3. Exact centered native residue modulo a power of two, umod_2exp_assign_r shall compute the unique mathematical residue u ∈ [0, m) congruent to a modulo an integer multiple of m. Let r = a − trunc(a ⁄ m)m.

When r ≥ 0, the operation shall store r exactly and return V_EQ for every valid request, without a hardware-direction prerequisite. When r < 0, it shall round and store r + m using the value, relation-precision, hardware-direction and exactness rules for native addition in 🔗 4. Rounding, result classes and state for finite native binary arithmetic. The returned relation shall compare the exact mathematical u with the stored value. A directed upward or delegated bound may equal m when u is not representable; the rounded value shall not be reduced again. ROUND_NOT_NEEDED shall require u to be exactly representable. If the mathematical residue is zero, the stored zero shall retain the source sign.

The operation shall preserve the hardware direction. Backend setup, live objects, synchronization, aliases, source preservation, initialization independence and floating-point exception conditions shall follow 🔗 4. Rounding, result classes and state for finite native binary arithmetic. No coefficient-range limit or irrational-precision setting shall restrict the calculation.