Parma Polyhedra Library requirements
C++ same-storage native integer unary arithmetic

C++ same-storage native integer unary arithmetic

PPL-SPEC-000835
1. Native integer floor, ceiling and truncation identity
UID: PPL-SPEC-000835
STATUS: APPROVED
COMPONENT: NUMERICS
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

For the eleven standard native integer storage types and same-storage raw/checked argument forms in 🔗 1. Exact same-storage native integer arithmetic, floor_assign_r, ceil_assign_r and trunc_assign_r shall assign the source integer unchanged and return V_EQ. Every valid rounding request, with or without ROUND_STRICT_RELATION, shall have this identity behavior.

The entry source shall be finite under its policy and within the selected destination policy's finite interval. The source and output may be the same object; distinct sources shall remain unchanged. Named calls shall require no rounding default or policy result handler and invoke no handler. The lifetime, synchronization, initialization and hardware-direction conditions of 🔗 1. Exact same-storage native integer arithmetic shall apply.

RATIONALE:

Applying an integral rounding operation to an integer must preserve every finite bit value, including its range endpoints and source aliases.

INTERFACE:

Public header: <ppl.hh>; effective instantiations in Parma_Polyhedra_Library for admitted argument types:

Result floor_assign_r(To& to, const From& source, Rounding_Dir dir);
Result ceil_assign_r(To& to, const From& source, Rounding_Dir dir);
Result trunc_assign_r(To& to, const From& source, Rounding_Dir dir);
VERIFICATION_CRITERIA:

For every standard native integer type and admitted policy reservation combination, check finite endpoints and interior signed/unsigned values under all eight requests. Verify raw/checked argument combinations, same object assignment, unchanged distinct sources, exact result codes, no handler calls and preserved hardware direction without initialization.

SOURCE:

src/checked_int_inlines.hh; src/checked_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; src/checked_ext_inlines.hh; tests/nativeintegerunaryspec1.cc.

2. Native integer negation and absolute value
UID: PPL-SPEC-000836
STATUS: APPROVED
COMPONENT: NUMERICS
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

For the same-storage native integer argument forms and entry-value preconditions in 🔗 1. Exact same-storage native integer arithmetic, neg_assign_r shall assign  − x and abs_assign_r shall assign |x| whenever that mathematical integer is within the selected destination's finite interval. Each successful operation shall return V_EQ for every valid rounding request, with or without ROUND_STRICT_RELATION. Zero shall remain zero; unsigned absolute value shall preserve its source value.

When the selected destination enables overflow checking, an exact result outside its finite interval shall have the inward endpoint, admitted outward infinity or unrepresentability outcome of 🔗 4. Checked native arithmetic range outcomes. In particular, negating a nonzero unsigned integer shall not report a wrapped unsigned value as successful exact negation. A signed minimum's positive negation or absolute value shall be range-checked when it is outside the destination interval. If checking is disabled, the result shall be representable as a precondition. ROUND_NOT_NEEDED shall require representability, including when a strict flag is present.

The source and output may be the same object; every calculation shall use the entry source value. Distinct sources shall remain unchanged. Calls shall require no rounding default or policy result handler and shall not invoke a handler, including when a range outcome is returned. Output reusability after unrepresentability, object lifetime, synchronization, initialization and hardware-direction conditions shall follow 🔗 1. Exact same-storage native integer arithmetic and 🔗 4. Checked native arithmetic range outcomes.

RATIONALE:

The positive magnitude of a signed minimum and the negative of an unsigned value require explicit range treatment even though the source itself is finite and valid.

INTERFACE:

Public header: <ppl.hh>; effective instantiations in Parma_Polyhedra_Library for admitted argument types:

Result neg_assign_r(To& to, const From& source, Rounding_Dir dir);
Result abs_assign_r(To& to, const From& source, Rounding_Dir dir);
VERIFICATION_CRITERIA:

Use independent unbounded negation/absolute-value oracles for all eleven native types, every policy reservation combination, signed minima, finite endpoints, zero and both signs. Check all valid requests, exact payloads, literal range codes, inward endpoints, enabled outward infinity, reusable unrepresentable outputs, raw/checked forms and both permitted aliases. Verify handler independence and preserved hardware direction.

SOURCE:

src/checked_int_inlines.hh; src/checked_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; src/checked_ext_inlines.hh; tests/nativeintegerunaryspec1.cc.