C++ same-storage native integer number-theoretic functions
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
Incoming link from:
6. Checked named nonnegative square root
1 |
For the eleven standard native integer storage types and same-storage raw/checked forms in 🔗 1. Exact same-storage native integer arithmetic, a finite nonnegative source x shall be admitted by sqrt_assign_r. ROUND_DOWN shall store ⌊√(x)⌋; ROUND_UP shall store ⌈√(x)⌉. ROUND_IGNORE shall use the floor convention. The result shall be finite and representable, including when forming its mathematical square or its successor's square would exceed native storage. The returned relation shall contain the exact nonnegative real square root's ordering relative to the stored integer. With ROUND_STRICT_RELATION it shall identify exactly equality, strict greater-than or strict less-than through V_EQ, V_GT or V_LT. ROUND_NOT_NEEDED shall require a perfect-square source, store its exact integer root and return a relation admitting equality; its strict form shall return V_EQ. Zero and one shall have their exact roots. No negative-input rejection guarantee shall be inferred from the nonnegative domain. The source and destination may be the same object; distinct sources shall remain unchanged. Calls shall require no rounding default, policy handler, floating-point conversion, FPU setup, irrational-precision setting or library initialization. They shall not invoke a result handler and shall preserve hardware direction. Live-object and synchronization prerequisites shall follow 🔗 1. Exact same-storage native integer arithmetic. |
An integer root can be computed and checked exactly without an inexact floating conversion or a native-width square used as an oracle. |
|
|
|
|
|
Use independent unbounded integer root/remainder oracles and both root inequalities, every nonnegative eight-bit input, all native storage types, large perfect squares and their neighbors, finite maxima, raw/checked forms and source aliases. Check each admitted rounding/exactness request, result relation, unchanged sources and hardware direction without initialization. |
src/checked_int_inlines.hh; src/checked_inlines.hh; src/checked_ext_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/nativeintegerfunctionspec1.cc. |
|
|
Public header: <ppl.hh>; effective instantiations in Parma_Polyhedra_Library for admitted argument types: Result sqrt_assign_r(To& to, const From& source, Rounding_Dir dir); |
||
|
SW_SPEC
|
2 |
|
|
|
For the same-storage finite entry operands and prerequisites in 🔗 1. Exact same-storage native integer arithmetic, gcd_assign_r shall assign the nonnegative integer g = gcd(a, b). Two zero sources shall give zero; one zero source shall give the other source's absolute value. lcm_assign_r shall give zero when either source is zero, without requiring a representable absolute value of the other source. Otherwise it shall assign the positive integer |a ⁄ g| |b|. For a finite representable result, each operation shall return V_EQ for every valid rounding request, including a strict flag. With overflow checking enabled, a nonnegative exact result outside the selected policy's finite interval shall have the positive-range outcome of 🔗 4. Checked native arithmetic range outcomes. Checked acquisition of a nonrepresentable source absolute value during a nonzero least-common-multiple calculation shall have that same positive-range outcome; no wrapped magnitude shall be a successful finite answer. If checking is disabled, the result and each needed source absolute value or native arithmetic intermediate shall be finite and representable. ROUND_NOT_NEEDED shall require representability of the selected operation and its necessary intermediates. The destination may alias either source, the sources may share an object, and all three arguments may be the same object. Every mathematical operand shall mean its entry value. Distinct sources shall remain unchanged. Calls shall require no rounding defaults or result handlers and shall invoke no handler, including on a range outcome. Object lifetime, synchronization, initialization, hardware-direction preservation and output reusability after an unrepresentable result shall follow 🔗 1. Exact same-storage native integer arithmetic and 🔗 4. Checked native arithmetic range outcomes. |
Number-theoretic results have nonnegative mathematical meanings independent of source signs. Zero multiples and a representable remainder sequence need not acquire an unrepresentable signed minimum magnitude. |
|
|
|
|
|
Compare all source signs, zeros, common factors, coprime inputs and finite endpoints with independent unbounded gcd/lcm oracles. Check every standard native type, reservation policy, valid request, source/output alias and raw/checked argument position. Assess nonrepresentable nonnegative results and checked absolute-value acquisition with literal range codes, no handler dispatch, preserved distinct sources and reusable outputs. |
src/checked_int_inlines.hh; src/checked_inlines.hh; src/checked_ext_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/nativeintegerfunctionspec1.cc. |
|
|
Public header: <ppl.hh>; effective instantiations in Parma_Polyhedra_Library for admitted argument types: Result gcd_assign_r(To& to, const X& x, const Y& y, Rounding_Dir dir); Result lcm_assign_r(To& to, const X& x, const Y& y, Rounding_Dir dir); |