Parma Polyhedra Library requirements
C++ finite native floating-to-integral conversion
1. Supported finite native floating-to-integral scalar conversion PPL-SPEC-000241

The source shall be a finite float, double or long double whose corresponding configured PPL_SUPPORTED_FLOAT, PPL_SUPPORTED_DOUBLE or PPL_SUPPORTED_LONG_DOUBLE is nonzero. Its mathematical value shall be the exact represented binary value, without a decimal approximation. A destination shall be one of the eleven native integral types or Checked_Number<T, Check_Overflow_Policy<T>> types in 🔗 1. Exact conversion between native and checked integral scalars. Native destinations shall use that overflow policy through their _r adapter and shall reserve no payload for infinity or NaN.

For an integral source value representable in the destination, assign_r shall assign that exact integer. Either sign of native floating-point zero shall produce integer zero. Directed ROUND_DOWN and ROUND_UP requests, with or without a strict flag, shall return V_EQ for these exact inputs. Delegated and no-rounding-needed classifications shall follow 🔗 3. Delegated floating-to-integral truncation and exactness requests.

The destination shall be a live assignable object and a distinct source shall remain unchanged. Callers shall prevent concurrent access to an object while another operation modifies it. No library initialization object, thread initialization or coefficient-constant stage shall be required. A directed request on a nonintegral source shall require the hardware rounding mode to be upward, as established by the rounding protocol in 🔗 4. Rounding-state exchange during an initialized thread lifetime; exact integral inputs shall not require a particular mode. Every call shall preserve the current hardware rounding direction. The _r interface shall return Result without policy-handler dispatch or automatic numeric overflow exceptions. Unavailable source types shall not be instantiated.

2. Directed finite floating-to-integral rounding within range PPL-SPEC-000242

For a finite source value a and admitted source/destination types from 🔗 1. Supported finite native floating-to-integral scalar conversion, ROUND_DOWN shall assign ⌊a⌋ and ROUND_UP shall assign ⌈a⌉ whenever that requested integer is representable. A nonintegral source shall require the upward hardware rounding mode in 🔗 1. Supported finite native floating-to-integral scalar conversion. An optional ROUND_STRICT_RELATION flag shall not change the mathematical result.

A nonintegral downward result shall return V_GT and a nonintegral upward result shall return V_LT, with exact-to-computed orientation from 🔗 1. Numerical result classes and relation meanings. An integral source shall return V_EQ. A source just outside the destination's integer endpoints whose requested rounded integer is an endpoint shall produce that ordinary definite relation, without an integer-range-overflow annotation. This shall include upward rounding of a negative proper fraction to unsigned zero.

Out-of-range rounded integers shall follow 🔗 4. Floating-to-integral range detection and reusable destinations. Source, object-synchronization, lifetime and hardware-mode preservation shall follow 🔗 1. Supported finite native floating-to-integral scalar conversion.

3. Delegated floating-to-integral truncation and exactness requests PPL-SPEC-000243

For admitted source and destination types in 🔗 1. Supported finite native floating-to-integral scalar conversion, ROUND_IGNORE shall assign trunc(a) toward zero when that integer is representable. With no strict flag, the successful conversion shall return V_LGE for integral and nonintegral source values. No particular current hardware direction shall be required for this truncating request.

ROUND_NOT_NEEDED shall require an exact integral source value representable in the destination. For that valid request, the integer value shall be preserved under any current hardware rounding direction. Without a strict flag, its result shall be V_EQ in an assertion-enabled build and may be lazy V_LGE in a build defining NDEBUG, following the internal request translation in 🔗 7. Internal no-rounding-needed request and result checking.

With ROUND_STRICT_RELATION, a delegated request shall determine the definite relation: V_GT for a positive inexact source truncated toward zero, V_LT for a negative inexact source, and V_EQ for an integral source. A strict no-rounding-needed request shall retain its exact integral precondition and return V_EQ. Range failures under delegated requests shall follow 🔗 4. Floating-to-integral range detection and reusable destinations. Object validity, source preservation and hardware-direction preservation shall follow 🔗 1. Supported finite native floating-to-integral scalar conversion.

4. Floating-to-integral range detection and reusable destinations PPL-SPEC-000244

For the admitted types and valid hardware prerequisites in 🔗 1. Supported finite native floating-to-integral scalar conversion, let q be the requested floor, ceiling or truncated integer defined by 🔗 2. Directed finite floating-to-integral rounding within range and 🔗 3. Delegated floating-to-integral truncation and exactness requests. If q lies below the destination minimum, ROUND_UP shall store that minimum and return V_LT_INF; ROUND_DOWN or ROUND_IGNORE shall return V_GT_MINUS_INFINITY | V_UNREPRESENTABLE. If q lies above the maximum, ROUND_DOWN shall store that maximum and return V_GT_SUP; ROUND_UP or ROUND_IGNORE shall return V_LT_PLUS_INFINITY | V_UNREPRESENTABLE. An optional strict flag shall not change these range outcomes.

A requested integer within range shall follow the ordinary classifications of 🔗 2. Directed finite floating-to-integral rounding within range and 🔗 3. Delegated floating-to-integral truncation and exactness requests. Checking range shall not itself require an undefined native floating-to-integer cast, including when a floating source format cannot represent the destination's maximum integer exactly. A failed range request shall not report a wrapped integer as successful. An unrepresentable result shall leave the destination assignable and destructible without a payload-value guarantee. ROUND_NOT_NEEDED shall exclude out-of-range inputs. These result codes shall be returned directly without automatic policy exception dispatch.