Parma Polyhedra Library requirements
C++ integer and rational special-value classification

C++ integer and rational special-value classification

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-000846
PPL-SPEC-000846
Policy-dependent native integer classification

The source shall have one of the eleven native integer storage types, either raw or wrapped as in 🔗 1. Exact same-storage native integer arithmetic. Every native integer payload shall denote its ordinary finite value or an admitted special representation according to the source policy. Reserved representations shall follow 🔗 1. Typed special-marker assignment to native integer storage. A raw native integer source shall have no reserved infinity or NaN patterns.

is_not_a_number(x) shall be true exactly for an admitted NaN; is_minus_infinity(x) and is_plus_infinity(x) shall be true exactly for their admitted signed infinities. infinity_sign(x) shall return  − 1 for negative infinity, 1 for positive infinity and zero for finite values and NaN. A representation reserved only by another policy shall not be interpreted as special under the source's own policy.

is_integer(x) shall return true for every finite native integer and each admitted signed infinity, and false for an admitted NaN. It shall recognize membership in the extended integral domain ℤ∪{ − ∞,  + ∞}. Ordinary membership in ℤ shall additionally require excluding both infinities.

For a checked source, classify(nan, inf, sign) shall apply these rules in order:

  • For a NaN, if nan or sign is true, return V_NAN.
  • If inf is true, return V_EQ_MINUS_INFINITY or V_EQ_PLUS_INFINITY for an infinity of the corresponding sign.
  • If sign is true, return V_LT for a negative value, V_GT for a positive value and V_EQ for zero. This shall include an infinity whose infinity classification was not requested.
  • Otherwise return V_LGE, including for NaN when neither NaN nor sign classification was requested.

Omitted arguments shall request all three classifications. Normal relation codes in this query shall classify the source's sign relative to zero; they shall not describe an arithmetic rounding error. No overflow or unrepresentability flag shall be added. The classes and relations shall have the meanings of 🔗 1. Numerical result classes and relation meanings.

Sources shall be live and remain unchanged, and access overlapping mutation shall be synchronized. Calls shall require no library initialization, coefficient-constant stage, FPU setup, rounding default or policy handler. They shall invoke no handler and preserve hardware direction.

A native bit pattern can denote a finite endpoint under one policy and a special value under another. Classification must honor the selected policy and the requested information. Extended integrality includes admitted infinities while distinguishing NaN from integer values.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Check all eleven storage types and reserved-value policy combinations, including every eight-bit payload and larger finite/reserved boundaries. Use independent literal policy/representation oracles, all eight Boolean classification requests, default arguments and raw/checked predicates. Check negative infinity in unsigned storage, NaN request precedence, extended integrality of finite values and admitted infinities, NaN rejection, source preservation and hardware independence without initialization.

src/checked_int_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/scalarclassificationspec1.cc.

CPP
Public

Public header: <ppl.hh>; effective query instantiations in Parma_Polyhedra_Library for admitted N:

bool is_not_a_number(const N& x);
bool is_minus_infinity(const N& x);
bool is_plus_infinity(const N& x);
int infinity_sign(const N& x);
bool is_integer(const N& x);

For an admitted Checked_Number source, the member interface shall be:

Result classify(bool nan = true, bool inf = true,
                bool sign = true) const;
SW_SPEC
2
PPL-SPEC-000847
GMP integer and rational special-value classification

The source shall be raw mpz_class or mpq_class, or an admitted Checked_Number<T, Policy> with either underlying type. It shall contain a finite valid value, or a PPL special representation admitted by its own policy as in 🔗 2. Typed special-marker assignment to GMP integer and rational storage. Finite rational sources shall be canonical with a positive nonzero denominator as in 🔗 1. Exact rational assignment from rational and integral sources. Raw GMP sources shall have their native transparent source policy and shall admit only its supported representations.

is_not_a_number(x) shall be true exactly for an admitted NaN; is_minus_infinity(x) and is_plus_infinity(x) shall be true exactly for their admitted signed infinities. infinity_sign(x) shall return  − 1 for negative infinity, 1 for positive infinity and zero for finite values and NaN. A representation reserved only by another policy shall not be interpreted as special under the source's own policy.

is_integer(x) shall return true for every finite mpz_class value, for a finite canonical mpq_class exactly when its denominator is one, and for each admitted signed infinity. It shall return false for an admitted NaN. It shall recognize the extended integral domain ℤ∪{ − ∞,  + ∞}; ordinary membership in ℤ shall additionally require excluding both infinities.

For a checked source, classify(nan, inf, sign) shall apply these rules in order:

  • For a NaN, if nan or sign is true, return V_NAN.
  • If inf is true, return V_EQ_MINUS_INFINITY or V_EQ_PLUS_INFINITY for an infinity of the corresponding sign.
  • If sign is true, return V_LT for a negative value, V_GT for a positive value and V_EQ for zero. This shall include an infinity whose infinity classification was not requested.
  • Otherwise return V_LGE, including for NaN when neither NaN nor sign classification was requested.

Omitted arguments shall request all three classifications. Normal relation codes in this query shall classify the source's sign relative to zero; they shall not describe an arithmetic rounding error. No overflow or unrepresentability flag shall be added. The classes and relations shall have the meanings of 🔗 1. Numerical result classes and relation meanings.

Sources shall be live and remain unchanged, and access overlapping mutation shall be synchronized. Calls shall require no library initialization, coefficient-constant stage, FPU setup, rounding default or policy handler. They shall invoke no handler and preserve hardware direction.

A supported PPL special representation shall be inspected through the PPL queries rather than ordinary GMP numerical operations. Available resources shall suffice for the source objects. Unbounded finite magnitudes shall not be classified as infinities. Native floating-point classification shall retain 🔗 1. Native floating-point NaN and infinity predicates and 🔗 2. Selective classification of native floating-point checked values.

GMP finite values and PPL special representations have separate numerical domains. Selective classification gives clients the requested sign or class without treating an unbounded magnitude as an overflow sentinel. The shared extended-integrality convention separates the accepted infinities from NaN without confusing ordinary integer membership with extended membership.

APPROVED
NUMERICS
IF_CPP, SCALAR_MPZ, SCALAR_MPQ
Test, Analysis, Inspection

For both GMP types, check zero, both finite signs, large magnitudes and admitted NaN/infinities under every policy combination. Include canonical proper fractions and very small nonzero rationals. Check all Boolean classification requests, default arguments, raw/checked predicates, extended integrality and ordinary finiteness distinctions, source representation preservation, no handler calls and hardware independence without initialization.

src/checked_mpz_inlines.hh; src/checked_mpq_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/scalarclassificationspec1.cc.

CPP
Public

Public header: <ppl.hh>; effective query instantiations in Parma_Polyhedra_Library for admitted N:

bool is_not_a_number(const N& x);
bool is_minus_infinity(const N& x);
bool is_plus_infinity(const N& x);
int infinity_sign(const N& x);
bool is_integer(const N& x);

For an admitted Checked_Number source, the member interface shall be:

Result classify(bool nan = true, bool inf = true,
                bool sign = true) const;