Parma Polyhedra Library requirements
C++ same-storage native integer number-theoretic functions
PPL-SPEC-000840
1. Directed native integer square-root assignment PPL-SPEC-000840

For the eleven standard native integer storage types and same-storage raw/checked forms in 🔗 1. Exact same-storage native integer arithmetic, a finite nonnegative source x shall be admitted by sqrt_assign_r. ROUND_DOWN shall store ⌊√(x)⌋; ROUND_UP shall store ⌈√(x)⌉. ROUND_IGNORE shall use the floor convention. The result shall be finite and representable, including when forming its mathematical square or its successor's square would exceed native storage.

The returned relation shall contain the exact nonnegative real square root's ordering relative to the stored integer. With ROUND_STRICT_RELATION it shall identify exactly equality, strict greater-than or strict less-than through V_EQ, V_GT or V_LT. ROUND_NOT_NEEDED shall require a perfect-square source, store its exact integer root and return a relation admitting equality; its strict form shall return V_EQ. Zero and one shall have their exact roots. No negative-input rejection guarantee shall be inferred from the nonnegative domain.

The source and destination may be the same object; distinct sources shall remain unchanged. Calls shall require no rounding default, policy handler, floating-point conversion, FPU setup, irrational-precision setting or library initialization. They shall not invoke a result handler and shall preserve hardware direction. Live-object and synchronization prerequisites shall follow 🔗 1. Exact same-storage native integer arithmetic.

2. Native integer greatest common divisor and least common multiple PPL-SPEC-000841

For the same-storage finite entry operands and prerequisites in 🔗 1. Exact same-storage native integer arithmetic, gcd_assign_r shall assign the nonnegative integer g = gcd(a, b). Two zero sources shall give zero; one zero source shall give the other source's absolute value. lcm_assign_r shall give zero when either source is zero, without requiring a representable absolute value of the other source. Otherwise it shall assign the positive integer |a ⁄ g| |b|.

For a finite representable result, each operation shall return V_EQ for every valid rounding request, including a strict flag. With overflow checking enabled, a nonnegative exact result outside the selected policy's finite interval shall have the positive-range outcome of 🔗 4. Checked native arithmetic range outcomes. Checked acquisition of a nonrepresentable source absolute value during a nonzero least-common-multiple calculation shall have that same positive-range outcome; no wrapped magnitude shall be a successful finite answer. If checking is disabled, the result and each needed source absolute value or native arithmetic intermediate shall be finite and representable. ROUND_NOT_NEEDED shall require representability of the selected operation and its necessary intermediates.

The destination may alias either source, the sources may share an object, and all three arguments may be the same object. Every mathematical operand shall mean its entry value. Distinct sources shall remain unchanged. Calls shall require no rounding defaults or result handlers and shall invoke no handler, including on a range outcome. Object lifetime, synchronization, initialization, hardware-direction preservation and output reusability after an unrepresentable result shall follow 🔗 1. Exact same-storage native integer arithmetic and 🔗 4. Checked native arithmetic range outcomes.