Internal numerical and common scalar helpers
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
|
For a nonzero value of unsigned int, unsigned long or unsigned long long with w value bits, clz shall return w − 1 − ⌊log2x⌋; ctz shall return the greatest k such that 2k divides x. Zero shall be outside their admitted input domain. msb_position(x) shall return the zero-based position ⌊log2x⌋ of a nonzero unsigned long long. The Implementation::first_one and Implementation::last_one overloads for the same three unsigned types shall return the least and greatest set-bit indices, respectively. All functions shall preserve their input and require no library initialization. |
Bit positions drive exact normalization and representation operations; zero has no admitted highest or lowest set bit. |
|
|
|
|
|
Check every single-bit position, adjacent values, alternating masks, all-one values and reproducible pseudorandom nonzero values against independent bit-by-bit oracles. Exercise the compiler-intrinsic path and the standard-library fallback against independent bit-by-bit oracles. |
src/compiler.hh; src/Float_inlines.hh; tests/commonhelpersspec1.cc; tests/portablebitsspec1.cc; src/Bit_Row_inlines.hh; tests/scalaradaptersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. unsigned clz(unsigned int); unsigned clz(unsigned long); unsigned clz(unsigned long long); unsigned ctz(unsigned int); unsigned ctz(unsigned long); unsigned ctz(unsigned long long); unsigned msb_position(unsigned long long); namespace Implementation { unsigned first_one(unsigned int); unsigned last_one(unsigned int); unsigned first_one(unsigned long); unsigned last_one(unsigned long); unsigned first_one(unsigned long long); unsigned last_one(unsigned long long); } |
||
|
SW_SPEC
|
2 |
|
|
|
hash_code_from_dimension(d) shall return d − 231⌊d ⁄ 231⌋ as int32_t. least_significant_one_mask(d) shall return zero for zero, and otherwise the single-bit mask of the least significant one in d. For 0 ≤ n ≤ m, compute_capacity(n,m) shall return 2(n + 1) when n < ⌊m ⁄ 2⌋, and m otherwise. Its result shall be representable and lie in [n, m]. For a live random-access container, nth_iter(c,n) shall return c.begin()+n with the corresponding mutable or const iterator type. The offset shall be representable in the container's difference_type and shall designate an element or the past-the-end position. No element shall change. is_space(c) shall apply the active C locale's whitespace classification to static_cast<unsigned char>(c); every char value shall be admitted, including negative values on signed-char targets. These helpers shall require no library initialization. |
Storage calculations must retain representable capacities and iterator offsets, while character classification must admit every character representation. |
|
|
|
|
|
Enumerate small requested/maximum pairs and boundary maxima; compare hashes and masks with literal modular/bit oracles. Check mutable and const iteration including the end position, and every unsigned-character byte in the C locale. |
src/globals_defs.hh; src/globals_inlines.hh; tests/commonhelpersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. int32_t hash_code_from_dimension(dimension_type); dimension_type least_significant_one_mask(dimension_type); dimension_type compute_capacity(dimension_type, dimension_type); template <typename C> typename C::iterator nth_iter(C&, dimension_type); template <typename C> typename C::const_iterator nth_iter(const C&, dimension_type); bool is_space(char); |
||
|
SW_SPEC
|
3 |
|
|
|
For a live native scalar T, external_memory_in_bytes shall return zero and total_memory_in_bytes shall return sizeof(T). For a live mpz_class, external memory shall equal its allocated limb count multiplied by PPL_SIZEOF_MP_LIMB_T. For a live mpq_class, it shall equal the sum of its numerator's and denominator's external memory. Total GMP scalar memory shall add the corresponding scalar object's sizeof. These functions shall preserve values and allocations. The reported sum and products shall be representable in memory_size_type. They shall account for the scalar's owned storage, without measuring allocator bookkeeping or shared library state. The checked-wrapper forwarding rule shall remain 🔗 5. Checked scalar memory-size inspection. |
Container accounting composes scalar-owned limb allocations and must distinguish them from the inline scalar object. |
|
|
|
|
|
Use native scalar families, preallocated GMP zeros, large integers and rational numerator/denominator allocations; compare the reported sizes with GMP allocation fields and object sizes, preserving source values. |
src/globals_inlines.hh; tests/commonhelpersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. template <Native_Number T> memory_size_type external_memory_in_bytes(const T&); template <Native_Number T> memory_size_type total_memory_in_bytes(const T&); memory_size_type external_memory_in_bytes(const mpz_class&); memory_size_type total_memory_in_bytes(const mpz_class&); memory_size_type external_memory_in_bytes(const mpq_class&); memory_size_type total_memory_in_bytes(const mpq_class&); |
||
|
SW_SPEC
|
4 |
|
|
|
For live admitted T objects, assign_or_swap(to,from) shall select exactly one strategy at compile time. If Has_Assign_Or_Swap<T>::value is true, it shall call to.assign_or_swap(from) once. Otherwise, if Slow_Copy<T>::value is false, it shall perform to=from once. Otherwise it shall perform one unqualified swap(to,from) with std::swap available. The selected operation shall determine the values, source modification, alias admissibility and exception guarantees; its exceptions shall propagate. GMP integer and rational swap adapters shall exchange the owned values, preserving independent valid storage. A slow-copy type used with the generic PPL swap shall require an applicable specialization; the unspecialized generic form shall fail to instantiate. For T with a detected bool OK() const member, f_OK(t) shall return t.OK(). Its native scalar and GMP scalar overloads shall return true. Calling f_OK shall retain the selected object's invariant-query prerequisites and exception behavior. |
Generic storage algorithms must use the declared transfer and invariant capabilities of their element type without imposing extra copies. |
|
|
|
|
|
Use instrumented types to distinguish all three strategies, returned effects, self operands where admitted and thrown exceptions. Check GMP value/allocation exchange and true/false invariant callbacks; inspect the compile-time rejection for unspecialized slow-copy swap. |
src/assign_or_swap.hh; src/globals_defs.hh; src/mp_std_bits_inlines.hh; tests/commonhelpersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. namespace Parma_Polyhedra_Library { template <typename T> void assign_or_swap(T&, T&); // Constraints select the three strategies described above. template <typename T> bool f_OK(const T&); } // Global overloads found by argument-dependent lookup: void swap(mpz_class&, mpz_class&); void swap(mpq_class&, mpq_class&); |
||
|
SW_SPEC
|
5 |
|
|
|
For an admitted Representation equal to DENSE or SPARSE, ascii_dump shall insert exactly DENSE or SPARSE, respectively. ascii_load shall extract one whitespace-delimited string and accept exactly either of those case-sensitive tokens, assigning the corresponding selector and returning true. A normally failed extraction or any other token shall return false and preserve the destination selector. A complete accepted record shall leave following tokens available. Stream exceptions shall propagate according to the stream's exception mask; output shall preserve the selector. Neither function shall require library initialization. |
Storage representation names need a small stable grammar independent of numerical scalar serialization. |
|
|
|
|
|
Check both literal records, overwrite both destinations, suffix retention, whitespace, wrong case, unknown/empty input and ordinary or throwing stream failures. |
src/globals_inlines.hh; tests/commonhelpersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. void ascii_dump(std::ostream&, Representation); bool ascii_load(std::istream&, Representation&); |
||
|
SW_SPEC
|
6 |
|
|
|
The internal Implementation short-sum helpers shall operate on two or three addends per list. Each pointer shall designate a live admitted scalar. Original left addends shall be finite; right addends may additionally be positive infinity. NaN and negative infinity shall be outside the admitted domain. The scalar policy and arithmetic shall supply sound upward/downward bounds, valid overflow outcomes, and exact rational conversion of each finite original addend. Required rounding setup, resources and synchronization shall follow those scalar operations. checked_sum_assign<Count> shall evaluate the first two addends and then, for three terms, add the third, using the requested direction. It shall return true exactly when every addition reports V_EQ; false shall not by itself assert that the final mathematical sum is inexact. Its output shall be independent of all input addend storage. checked_sum_has_infinite_right shall return true exactly when an original right addend is positive infinity. checked_sum_less shall return exactly ∑iLi < ∑jRj, including finite sums outside the bounded scalar range. A positive-infinite original right operand shall make this predicate true before sum arithmetic is attempted. A finite rounded overflow shall not be mistaken for an original infinite operand. The cached-left overload shall receive the same upward left sum and exactness flag produced by checked_sum_assign for those original left addends. checked_finite_sum_less shall additionally require all right addends finite. Directed bounds may decide the comparison only when they establish its truth or falsity. An unresolved comparison shall use exact rational arithmetic on the original finite addends. No input addend shall change. |
Strict comparison of original bounds must survive cancellation, coincident rounded images and finite overflow. Sound directed filters avoid exact arithmetic only when the ordering is proved. |
|
|
|
|
|
Compare all four two/three-term arities and cached/uncached forms with independent exact rational sums. Include equality, different rounded images, cancellation, subnormal operands, finite prefix overflow, and positive infinity in every right-hand position. Exercise exact GMP and supported floating scalars. |
src/Checked_Number_templates.hh; tests/checkedsumsspec1.cc; tests/BD_Shape; tests/Octagonal_Shape. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. namespace Implementation { template <unsigned Count, typename N> bool checked_sum_assign(N&, const N* const*, Rounding_Dir); template <unsigned L, unsigned R, typename N> bool checked_sum_has_infinite_right(const N* const*, const N* const*); template <unsigned L, unsigned R, typename N> bool checked_finite_sum_less(const N* const*, const N* const*, const N&, bool); template <unsigned L, unsigned R, typename N> bool checked_sum_less(const N* const*, const N* const*); template <unsigned L, unsigned R, typename N> bool checked_sum_less(const N* const*, const N* const*, const N&, bool); } |
||
|
SW_SPEC
|
7 |
|
|
Incoming link from:
1. Conversion of policy-admitted scalar special values
1 |
The internal Checked::construct dispatch shall receive suitably aligned storage for one complete destination scalar object, with no live object requiring destruction there. For finite same-type, same-policy input, it shall copy-construct an independent scalar and return V_EQ. The generic different-type path shall first default-construct the destination, then apply the corresponding checked assignment with the requested rounding direction, returning that assignment's Result without invoking a policy handler. Admitted native/GMP exact constructor specializations shall directly construct the exact value and return V_EQ. The floating-to-GMP-integer constructor shall retain 🔗 6. Finite native floating-point placement construction of an unbounded integer; supported floating-to-rational construction shall preserve the exact finite floating value. Special-value routing shall follow 🔗 1. Typed special construction in native scalar storage and the destination policy's capabilities. The internal assign_exact adapter shall assign the admitted exactly representable source to a live destination and return V_EQ without a handler. It shall not perform rounding. Source values shall be preserved and owned GMP values shall be independent. Underlying constructor, assignment and resource exceptions shall propagate. A destination whose construction itself throws shall not be used or destroyed as a completed object; if assignment throws after default construction, that underlying scalar shall remain live with the assignment's failure guarantees. These raw construction paths shall not be required by the ordinary converting Checked_Number constructors of 🔗 2. Finite checked scalar converting construction and assignment. |
Placement construction begins a scalar lifetime and must remain distinct from assignment to a live wrapper member. |
|
|
|
|
|
Construct into aligned raw storage, verify values, results, independence and explicit destruction for exact native/GMP and rounded native conversions. Include same-type and cross-type dispatch, special routing and a policy handler that must not run. Inspect constructor-versus-assignment exception lifetime boundaries. |
src/checked_inlines.hh; src/checked_ext_inlines.hh; src/checked_mpq_inlines.hh; src/checked_mpz_inlines.hh; tests/rawnumericspec1.cc. tests/smallconstantassign1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. namespace Checked { template <typename To_Policy, typename From_Policy, typename To, typename From> Result construct(To&, const From&, Rounding_Dir); template <typename To_Policy, typename From_Policy, typename To, typename From> Result construct_ext(To&, const From&, Rounding_Dir); template <typename To_Policy, typename From_Policy, typename To, typename From> Result assign_exact(To&, const From&, Rounding_Dir); } |
||
|
SW_SPEC
|
8 |
|
|
|
For a configured supported native floating type T, Float<T>(v) shall retain the native value and expose its corresponding binary descriptor; value() shall return that stored native value. Representation access shall use standard-defined object-representation copies, without reading an inactive union member. Native padding shall not be interpreted as an integer field; x87 conversions shall preserve the 64-bit significand and 16-bit sign/exponent, ignoring native padding and the descriptor's high padding bits. The binary descriptor shall remain the active union member, including after default construction. Default construction shall leave the raw storage unspecified until the caller establishes a valid value or complete binary encoding. Reads shall require such initialization and an admitted encoding of the configured native format. Checked::pred_float(v) shall replace an admitted finite value or positive infinity with its immediate predecessor in that native format. succ_float(v) shall replace a finite value or negative infinity with its immediate successor. NaN and the opposite unbounded endpoint shall be outside the corresponding admitted input domain. Predecessor of either zero shall be the smallest negative subnormal; successor of either zero shall be the smallest positive subnormal. Approaching zero from the positive or negative side shall retain the corresponding zero sign. No rounding mode change shall be required. For supported native floating Raw, materialize_native_value shall return a value materialized at that native format under the active rounding direction when the configured evaluation format has excess precision or range; otherwise it shall return the input value. limit_precision for float and double shall apply PPL_CC_FLUSH: on GNU-compatible compilers this shall force a memory observation of the argument; on the portable fallback it shall merely mark the argument used. The long double overload shall do nothing. None of these helpers shall change the rounding direction. round_to_integer shall return the integral native floating value selected by the active hardware rounding direction. Its input shall be finite, and hardware setup and floating exceptions shall follow that native operation. |
Directed arithmetic needs native-format adjacent values and explicit handling of excess evaluation precision without changing the caller's rounding direction. |
|
|
|
|
|
Check supported native types against nextafter at signed zeros, subnormal/normal transitions, finite extrema and admitted infinities. Check wrapper values and binary views, active-direction integral rounding, materialized values and preserved hardware direction; inspect the GNU barrier and portable no-op selection. |
src/Float_inlines.hh; src/checked_float_inlines.hh; src/compiler.hh; tests/floatinghelpersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. template <typename T> class Float; // Supported native specializations: Float<T>::Float(); Float<T>::Float(T); T Float<T>::value(); namespace Checked { template <typename T> void pred_float(T&); template <typename T> void succ_float(T&); template <typename Raw> Raw materialize_native_value(const Raw&); void limit_precision(const float&); void limit_precision(const double&); void limit_precision(const long double&); float round_to_integer(float); double round_to_integer(double); long double round_to_integer(long double); } template <typename T> void PPL_CC_FLUSH(const T&); |
||
|
SW_SPEC
|
9 |
|
|
|
On an available configured backend, fpu_initialize_control_functions shall establish that its control operations are usable. The C99 backend shall probe downward and upward selection and restore its original direction on successful return; a failed selection shall throw std::logic_error. Initialization shall not promise restoration after a failed probe. fpu_get_rounding_direction shall report the selected hardware direction; fpu_set_rounding_direction shall select an admitted platform encoding. fpu_save_rounding_direction shall select its argument and return a token accepted by fpu_restore_rounding_direction. On C99 and SPARC backends, restoration shall recover the preceding direction. The optimized IA32 pair shall require the default upward entry state and shall restore that default; its token shall not encode an arbitrary preceding environment. No backend shall promise to restore the entire floating environment through this pair. fpu_check_inexact shall return zero for a definitely clear flag, one for a definitely set flag, or minus one when flag observation is unavailable, without clearing an observed flag. fpu_reset_inexact shall clear the observable inexact state. The IA32 reset shall require default upward rounding and may clear other arithmetic exception flags. C99/SPARC reset shall preserve other flags and the selected direction. Where the IA32 raw-register helpers are available, control/status reads shall return the corresponding x87 control or status word, control writes shall load the admitted x87 word, fpu_clear_status(bits) shall clear selected status bits, and fpu_clear_exceptions shall clear the x87 exception state. SSE control reads/writes shall access MXCSR when that unit is available. Inputs shall be valid hardware control words and callers shall own access to the current thread's environment; trap enables and encodings shall be valid for every operation attempted. These raw operations shall not affect another thread's state. The no-control backend's control/status functions shall throw std::logic_error rather than report successful control. |
Native checked arithmetic relies on backend control and status semantics, including the deliberately restricted IA32 save/restore protocol. |
|
|
|
|
|
Exercise available directions, upward save/restore, nested C99/SPARC changes, inexact observation/reset and retained status bits. Check IA32 raw control/status access with valid masked words and restore the complete original environment. Exercise every no-control stub and inspect backend selection. |
src/fpu_defs.hh; src/fpu-c99_inlines.hh; src/fpu-ia32_inlines.hh; src/fpu-sparc_inlines.hh; src/fpu-none_inlines.hh; tests/fpu1.cc; tests/fpunonespec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless a nested namespace is shown. Template excerpts omit constraints where stated in the text. void fpu_initialize_control_functions(); fpu_rounding_direction_type fpu_get_rounding_direction(); void fpu_set_rounding_direction(fpu_rounding_direction_type); fpu_rounding_control_word_type fpu_save_rounding_direction(fpu_rounding_direction_type); void fpu_restore_rounding_direction(fpu_rounding_control_word_type); void fpu_reset_inexact(); int fpu_check_inexact(); // IA32 raw helpers, when available: int fpu_get_control(); void fpu_set_control(int); int fpu_get_status(); void fpu_clear_status(unsigned short); void fpu_clear_exceptions(); unsigned sse_get_control(); void sse_set_control(unsigned); |
||
|
SW_SPEC
|
10 |
|
|
|
native_interval_relation<Halve>() shall require finite native bounds, a positive magnitude a, a positive modulus m and exact unbounded native arithmetic. With h = 2 when Halve is true and h = 1 otherwise, its admitted affine interval shall be nonempty: L = c − a neg_lower ⁄ h ≤ U = c + a upper ⁄ h, where c is expr.inhomogeneous_term(). The selected halving operation shall be exact. The result shall be disjoint exactly when [L, U]∩mℤ is empty. It shall be included and saturating exactly when L = U ∈ mℤ. Otherwise it shall strictly intersect. Expression, magnitude, modulus and supplied bounds shall be preserved. Supported numerical and allocation failures may propagate; temporaries shall release their owned resources. Numerical initialization, lifetime and synchronization prerequisites shall follow 🔗 1. Bounded-difference values, numerical profiles and valid use and 🔗 1. Octagonal values, numerical profiles and valid use for the calling domain. |
A convex affine image meets a modulus lattice according to its two endpoints; computing both together permits one expression classification. |
|
|
|
|
|
Compare results with independently enumerated lattice levels for positive, negative, zero and fractional endpoints, nonzero offsets, multiple magnitudes, congruent and incongruent singletons, narrow gaps and nontrivial intervals. Exercise both halving choices. Check domain queries against analytic images, including general expressions, empty and unbounded sets and cold/warm caches. |
src/Shape_Congruence_Queries.hh; src/BD_Shape_templates.hh; src/Octagonal_Shape_templates.hh; tests/shapequerycertificatespec1.cc. |
|
|
Internal source header: Shape_Congruence_Queries.hh; namespace Parma_Polyhedra_Library::Implementation::Shape_Congruence_Queries. template <bool Halve, typename N> Poly_Con_Relation native_interval_relation( const Linear_Expression& expr, const Coefficient& magnitude, const N& neg_lower, const N& upper, const Coefficient& modulus); |
||
|
SW_SPEC
|
11 |
|
|
|
For each standard native integer storage type other than bool, the internal Checked::Integer_Overflow::add, sub and mul primitives shall accept two values and a destination of the same storage type. They shall return true exactly when the mathematical result lies outside that storage type's native range. They shall always assign the value congruent to the result modulo 2N, with N the storage width, including on overflow. The destination may alias either input. Available compiler builtins and portable emulations shall satisfy the same contract without overflowing signed arithmetic. Policy-reserved infinity and NaN representations, rounding directions and result handlers shall remain the responsibility of the checked-arithmetic layer. Selection of a builtin shall not change 🔗 1. Exact same-storage native integer arithmetic or 🔗 4. Checked native arithmetic range outcomes. When the corresponding builtin is unavailable or explicitly disabled, the checked-arithmetic layer shall retain its existing wider-carrier and range guard algorithms, without runtime dispatch to an alternative implementation. |
Separate machine-range detection from checked-number policy semantics. Select the builtin path only for signed, checked, finite-only policies with no configured wider carrier. Retain established arithmetic paths where builtin replacement has no measured benefit. In particular, no-builtin configurations need no new arithmetic cost. Retain established checked arithmetic on i686: new kernels changed PIE code placement enough to regress unchanged operations. Compiler availability remains independent of target selection for checked arithmetic. |
|
|
|
|
|
Compare raw results against an independent mathematical integer oracle for all byte pairs, wider boundary pairs and deterministic wider random pairs. Check the result even on overflow, input/output aliases and constant expressions. Repeat with builtins disabled and with unsigned plain char. Run the existing checked arithmetic and accumulation tests with builtin and legacy paths, including directed overflow and reserved finite endpoints. Compare generated arithmetic code and representative workload timings. |
src/Integer_Overflow.hh; src/compiler.hh; src/checked_int_inlines.hh; tests/integeroverflowspec1.cc; tests/nativeintegerarithmeticspec1.cc; tests/nativeintegeraccumulationspec1.cc. |
|
|
Internal source header: Integer_Overflow.hh; namespace Parma_Polyhedra_Library::Checked::Integer_Overflow. template <typename T> constexpr bool add(T x, T y, T& out) noexcept; template <typename T> constexpr bool sub(T x, T y, T& out) noexcept; template <typename T> constexpr bool mul(T x, T y, T& out) noexcept; template <typename T> constexpr bool portable_add(T x, T y, T& out) noexcept; template <typename T> constexpr bool portable_sub(T x, T y, T& out) noexcept; template <typename T> constexpr bool portable_mul(T x, T y, T& out) noexcept; |
||
|
SW_SPEC
|
12 |
|
|
|
For the default raw scalar families admitted by 🔗 1. Finite checked scalar storage and copying, Checked::Safe_Conversion<To, From>::value shall be a constant-expression Boolean certificate. A true value shall certify that every admitted finite mathematical value of From is exactly representable as a finite To value. Native floating values shall mean their exact stored binary values; finite rational storage shall be canonical. Unbounded storage shall require sufficient resources. The certificate shall concern finite values, not the policy-dependent handling of infinities or NaNs. Identical types shall have a true certificate, including identical nonnumeric types; the numerical guarantee shall concern admitted numerical types only. The unspecialized different-type case shall be false. The supplied numerical specializations may be conservative: false shall mean that no certificate is provided, rather than that every conversion loses information. This trait shall neither perform conversion nor admit additional scalar types. Its use shall require no runtime inspection, allocation, rounding change or policy handler. Consumers shall retain their own operand and operation prerequisites, including 🔗 1. Exact scalar sign and ordering, 🔗 2. Mixed finite floating and exact scalar ordering and 🔗 3. Best bounded-difference enclosure of Cartesian boxes. |
Comparison and domain conversion share a finite-value embedding certificate without acquiring a common runtime conversion path. |
|
|
|
|
|
Check every supplied true certificate against independently derived signed ranges, floating precision and exponent limits, including subnormal extents, and the unbounded integer/rational cases. Check identical types and default false cases. Exercise mixed scalar comparisons and domain conversions with their existing finite-value, special-value and policy controls. |
src/checked_inlines.hh; src/Shape_Conversion_Support.hh; tests/commonhelpersspec1.cc; tests/scalarorderingspec1.cc; tests/bdshapeconversionsspec1.cc. |
|
|
Internal source header: checked_inlines.hh; namespace Parma_Polyhedra_Library::Checked. template <typename To, typename From> struct Safe_Conversion; // Safe_Conversion<To, From>::value |
||
|
SW_SPEC
|
13 |
|
|
|
With its default third template argument, Fit<T, v> shall report true exactly when the long long value v is representable in the unqualified native integer type T admitted by C_Integer_Type. This includes plain char with its configured signedness. Other types, including bool, GMP classes, cv-qualified or reference types, and a non-void third argument, shall use the false primary template. Constant<v, prefer_signed> shall expose value_type and value through the standard std::integral_constant interface. Its value shall be exactly v. It shall select the first representable rank in this order: signed char/unsigned char, short/unsigned short, int/unsigned int, long/unsigned long, then long long. Within each of the first four ranks it shall select the preferred signedness when both candidates fit, otherwise the candidate that fits. The default preference shall be signed. The final fallback shall always be signed long long, including when unsigned is preferred. Plain char, bool and unsigned long long shall not be selection candidates. C_Integer shall provide the predecessor types for this rank traversal. Constant_ shall implement the recursion; nondefault implementation parameters shall not form part of this selection interface. The traits shall be usable in constant expressions and require no runtime initialization, allocation, conversion, policy handler or FPU rounding control. |
Representability and integer rank selection supply compile-time constants without relying on an incidental platform data model. |
|
|
|
|
|
Check representability against an independent mathematical integer oracle at signed and unsigned boundaries for every admitted native integer type. Check selection against an independent ordered candidate list, with both signedness preferences, zero, negative values and each rank boundary, including the signed-long-long fallback. Check excluded types and nondefault implementation parameters separately. |
src/globals_defs.hh; src/C_Integer.hh; tests/commonhelpersspec1.cc; tests/numericlimitsspec1.cc. |
|
|
Internal source headers: globals_defs.hh and C_Integer.hh; namespace Parma_Polyhedra_Library. template <typename T, long long v, typename Enable = void> struct Fit; template <long long v, bool prefer_signed = true> struct Constant; |
||
|
SW_SPEC
|
14 |
|
|
|
For each native floating type admitted by the configured PPL support flags, the probe shall check gradual underflow when numeric_limits reports a binary format with subnormals. Exact halving and restoration of the least positive normal shall preserve positive and negative subnormal values. Dividing the least positive/negative subnormal by the positive least subnormal shall yield positive/negative one, thereby checking that subnormal inputs are not flushed. Volatile loads and stores shall force the intended native runtime operations. Other formats and unselected types shall be skipped without claiming that the probe ran for them. Failure shall identify the type and failed condition. The C entry point shall return the C++ probe's success as 0, or failure as 1. This is a check of the calling process's numerical environment, not a promise to configure FPU rounding, exception masks or universal subnormal support. |
The C entry point and native helper must exercise the same gradual-underflow probe. |
|
|
|
|
|
Run the standalone C++ and mixed C/C++ probes with strict floating semantics; inspect configured omissions and independently check the exact native values. |
tests/fpu_gradual_underflow.hh; tests/fpu_c_main.c; tests/fpu_c_helper.cc. |
|
|
check_gradual_underflow<T>, check_supported_gradual_underflow and the mixed C/C++ probe entry points. |