C++ finite native operations with powers of two
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
|
The source and destination shall have the admitted same-format native or Checked_Number<F, Check_Overflow_Policy<F>> types in 🔗 4. Rounding, result classes and state for finite native binary arithmetic. The source shall be finite with represented value a. The exponent e shall be less than CHAR_BIT * sizeof(unsigned long long), and 2e shall be exactly representable and finite in F. add_2exp_assign_r shall compute a + 2e and sub_2exp_assign_r shall compute a − 2e. They shall assign the corresponding rounded value and return the result class/relation in 🔗 4. Rounding, result classes and state for finite native binary arithmetic. The power-of-two operand shall introduce no intermediate conversion error. Zero-result signs shall follow the addition/subtraction rules in 🔗 1. Finite native floating-point addition and subtraction with a positive second operand 2e. Source/destination aliases, source preservation, object validity, synchronization, direction and exactness prerequisites, native backend setup, initialization independence and floating-point exception conditions shall follow 🔗 4. Rounding, result classes and state for finite native binary arithmetic. Neither the source value nor the exponent shall be converted through the configured coefficient type. |
Adding an exactly represented power of two avoids an unintended source-constant approximation while retaining the ordinary native rounding and range rules. |
|
|
|
|
|
Check exponent zero, significand-neighbor exponents and the largest admitted exponent with exact integer/dyadic rational oracles. Include cancellation to signed zero, subnormals, precision-loss cases and finite range endpoints. Cross raw/checked forms, directed/delegated/strict statuses, nearest-even selection, aliases and hardware-state preservation. |
src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingdyadicspec1.cc. |
|
|
Public header: <ppl.hh>; effective template instantiations for admitted same-format To and From types: Result add_2exp_assign_r(To& to, const From& from, unsigned exp, Rounding_Dir dir); Result sub_2exp_assign_r(To& to, const From& from, unsigned exp, Rounding_Dir dir); |
||
|
SW_SPEC
|
2 |
|
|
Incoming link from:
5. Checked named scaling by powers of two
1 |
For the source/destination types, finite source value a and exponent preconditions in 🔗 1. Finite native addition and subtraction of a power of two, mul_2exp_assign_r shall compute a2e and div_2exp_assign_r shall compute a ⁄ 2e. They shall assign the rounded value and return the result class/relation in 🔗 4. Rounding, result classes and state for finite native binary arithmetic. The positive power-of-two operand shall be exact and nonzero. A zero result, including one caused by underflow, shall retain the source sign. A power-of-two scale shall not promise exactness when exponent-range or subnormal precision limits require approximation. Exponent zero shall preserve the represented source value; its status precision shall still follow the native binary arithmetic protocol. Source aliases, source preservation, object validity, synchronization, direction and exactness prerequisites, native backend setup, initialization independence and floating-point exception conditions shall follow 🔗 4. Rounding, result classes and state for finite native binary arithmetic. No bounded coefficient intermediate shall limit the native format's value range. |
Binary scaling is exact while the shifted significand fits the destination format, but underflow and range crossings still require explicit conservative outcomes. |
|
|
|
|
|
Use exact dyadic scaling oracles at exponent zero, precision boundaries and the largest admitted exponent. Exercise exact powers, signed zeros, normal/subnormal transitions, half-subnormal underflow, large finite magnitudes and inward range endpoints for raw/checked forms. Check tight rounded values, weak/strict/delegated statuses, aliases, source preservation and hardware direction. |
src/checked_float_inlines.hh; src/Checked_Number_defs.hh and src/Checked_Number_inlines.hh; tests/floatingdyadicspec1.cc. |
|
|
Public header: <ppl.hh>; effective template instantiations for admitted same-format To and From types: Result mul_2exp_assign_r(To& to, const From& from, unsigned exp, Rounding_Dir dir); Result div_2exp_assign_r(To& to, const From& from, unsigned exp, Rounding_Dir dir); |