Parma Polyhedra Library requirements
C++ native floating-point classification and special values

C++ native floating-point classification and special values

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-000321

The admitted storage type F shall be a configured supported native float, double or long double as in 🔗 1. Supported exact integer and rational conversion to native floating storage. T shall be F itself or Checked_Number<F, P>, where P is Check_Overflow_Policy<F>, Checked_Number_Transparent_Policy<F> or Extended_Number_Policy. A source shall contain a finite value, either infinity or a quiet NaN of that native format.

is_not_a_number(x) shall be true exactly for a NaN. is_minus_infinity(x) shall be true exactly for negative infinity, and is_plus_infinity(x) exactly for positive infinity. infinity_sign(x) shall return  − 1 for negative infinity, 1 for positive infinity and zero otherwise, including for a NaN and either signed zero. These queries shall not interpret a finite endpoint or a subnormal as an infinity.

The source shall be live and shall remain unchanged, including its zero sign. Concurrent access shall be prevented while another operation modifies it. No library initialization object, thread initialization or coefficient constant stage shall be required. Floating-point exceptions shall be nontrapping. Calls shall require no particular hardware rounding direction and shall preserve that direction. Floating-point exception-status flags shall be unspecified. Unavailable native source formats shall not be instantiated.

Numeric clients must distinguish ordinary finite values from unordered values and signed infinities before choosing valid arithmetic operations.

APPROVED
NUMERICS
IF_CPP, NATIVE_FP_AVAILABLE
Test, Analysis, Inspection

For every configured format and admitted policy, independently construct finite signed extrema, subnormals, signed zeros, quiet NaNs of both signs and both infinities. Check exact Boolean/sign answers for raw and wrapped sources under every hardware rounding mode. Preserve sources and direction; compile unavailable-format configurations without their instantiations.

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingclassificationspec1.cc; tests/numericpublic1.cc.

CPP
Public

Public header: <ppl.hh>; effective template instantiations for admitted T:

bool is_not_a_number(const T& x);
bool is_minus_infinity(const T& x);
bool is_plus_infinity(const T& x);
int infinity_sign(const T& x);
SW_SPEC
2
PPL-SPEC-000322
Selective classification of native floating-point checked values

For Checked_Number<F, P> with the storage types, policies and source values in 🔗 1. Native floating-point NaN and infinity predicates, classify(nan, inf, sign) shall return the following Result, applying these rules in order:

  • For a NaN, if nan or sign is true, it shall return V_NAN.
  • If inf is true, a negative infinity shall return V_EQ_MINUS_INFINITY and a positive infinity V_EQ_PLUS_INFINITY.
  • If sign is true, a negative value shall return V_LT, a positive value V_GT and either signed zero V_EQ. This rule shall include infinities whose infinity classification was not requested.
  • Otherwise it shall return lazy V_LGE. This shall include a NaN when neither NaN nor sign classification was requested.

The same requested-field rules shall apply to a custom policy providing the selected classification capabilities. A source shall not contain NaN when its policy has has_nan == false, nor infinity when it has has_infinity == false. Finite-only custom policies shall therefore admit every request mask on their valid finite sources.

Omitting arguments shall request all three classifications. A normal V_LT or V_GT shall characterize the value's sign relative to zero; it shall not describe an arithmetic rounding error. The class and relation fields shall have the meanings in 🔗 1. Numerical result classes and relation meanings. Source validity, availability, synchronization, initialization independence and floating-point state conditions shall follow 🔗 1. Native floating-point NaN and infinity predicates.

Selective classification permits a caller to request only the distinctions it needs while retaining the special unordered meaning of NaN when its sign is requested.

APPROVED
NUMERICS
IF_CPP, NATIVE_FP_AVAILABLE
Test, Analysis, Inspection

Exhaust all eight Boolean request combinations against an independent decision table for each admitted policy and configured format. Check positive/negative finite values, both zeros, subnormals, both infinities and quiet NaNs, plus the default all-true request. Verify exact Result codes, source preservation and unchanged hardware direction.

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingclassificationspec1.cc; tests/numericpublic1.cc.

CPP
Public

Public header: <ppl.hh>; member of the admitted Checked_Number<F, P>:

Result classify(bool nan = true, bool inf = true,
                bool sign = true) const;
SW_SPEC
3
PPL-SPEC-000323
PPL-SPEC-000323
Native floating-point extended integrality and quiet-NaN rejection

For an admitted raw or checked source type in 🔗 1. Native floating-point NaN and infinity predicates, is_integer(x) shall return true exactly when the source's represented binary value is a finite integer or an admitted signed infinity. It shall return false for a quiet NaN. Either signed zero shall be integral. This is membership in the extended integral domain ℤ∪{ − ∞,  + ∞}; infinity shall not thereby be identified with a member of ℤ. A caller requiring ordinary integer membership shall additionally exclude both infinities. Every finite representable value with zero fractional part shall be integral even when its magnitude exceeds every configured bounded coefficient range.

The result shall not depend on the current hardware rounding direction. Source validity, availability, preservation, synchronization, initialization independence and floating-point state conditions shall follow 🔗 1. Native floating-point NaN and infinity predicates.

Finite integrality is a property of the exact represented value rather than a chosen rounding direction or coefficient width. Accepting the admitted infinities gives the predicate the same extended-domain convention across the numerical backends; a separate finiteness check distinguishes ordinary integer membership.

APPROVED
NUMERICS
IF_CPP, NATIVE_FP_AVAILABLE
Test, Analysis, Inspection

Compare finite sources with independent significand/power-of-two rational oracles. Include both zeros, signed proper fractions, halves, subnormals, precision boundaries and finite maxima, both admitted signed infinities and quiet NaNs. Require identical answers under every hardware direction for raw and checked values, preserving source and direction.

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingclassificationspec1.cc; tests/numericpublic1.cc.

CPP
Public

Public header: <ppl.hh>; effective template instantiation for admitted T:

bool is_integer(const T& x);
SW_SPEC
4
PPL-SPEC-000324

For a live assignable destination of an admitted raw or checked type in 🔗 1. Native floating-point NaN and infinity predicates, assign_r from Minus_Infinity shall store negative infinity and return V_EQ_MINUS_INFINITY. Assignment from Plus_Infinity shall store positive infinity and return V_EQ_PLUS_INFINITY. Assignment from Not_A_Number shall store a quiet NaN and return V_NAN. These results shall be representable and shall not carry V_UNREPRESENTABLE. The supplied marker shall remain unchanged.

Infinity markers shall admit all four base directions in 🔗 4. Rounding-direction intent, composition and inspection, with or without ROUND_STRICT_RELATION. A NaN marker shall admit ROUND_DOWN, ROUND_UP and ROUND_IGNORE, with or without the strict flag. It shall not require an ordered NaN relation: V_NAN shall retain its empty relation. The _r interface shall return the result without policy-handler dispatch.

Callers shall prevent concurrent destination access while another operation modifies it. Configured-format availability, initialization independence and floating-point state conditions shall follow 🔗 1. Native floating-point NaN and infinity predicates. The value supplied on entry in the destination shall impose no numerical precondition on the replacement. The stored NaN's payload and sign shall be unspecified.

Typed markers let clients assign special values without depending on a native bit pattern or policy-specific sentinel representation.

APPROVED
NUMERICS
IF_CPP, NATIVE_FP_AVAILABLE
Test, Analysis, Inspection

Assign each marker to raw and admitted checked destinations for every valid direction/strict flag and hardware mode. Independently classify the stored values and signs with native facilities, require exact Result codes and representability, preserve marker and hardware direction, and replace previously finite, infinite and NaN destinations. Ensure result-returning NaN assignment does not dispatch a throwing extended-number policy.

src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingclassificationspec1.cc; tests/numericpublic1.cc.

CPP
Public

Public header: <ppl.hh>; effective template instantiation for admitted T and the three marker types Special:

Result assign_r(T& to, const Special& marker, Rounding_Dir dir);