Absorption of float operand
One addition or subtraction operand is absorbed by the other operand
Description
This defect occurs when one operand of an addition or subtraction operation is always negligibly small compared to the other operand. Therefore, the result of the operation is always equal to the value of the larger operand, making the operation redundant.
Risk
Redundant operations waste execution cycles of your processor.
The absorption of a float operand can indicate design issues elsewhere in the code. It is possible that the developer expected a different range for one of the operands and did not expect the redundancy of the operation. However, the operand range is different from what the developer expects because of issues elsewhere in the code.
Fix
See if the operand ranges are what you expect. To see the ranges, place your cursor on the operation.
If the ranges are what you expect, justify why you have the redundant operation in place. For instance, the code is only partially written and you anticipate other values for one or both of the operands from future unwritten code.
If you cannot justify the redundant operation, remove it.
If the ranges are not what you expect, in your code, trace back to see where the ranges come from. To begin your traceback, search for instances of the operand in your code. Browse through previous instances of the operand and determine where the unexpected range originates.
To determine when one operand is negligible compared to the other operand, the defect uses
rules based on IEEE® 754 standards. To fix the defect, instead of using the actual rules,
you can use this heuristic: the ratio of the larger to the smaller operand must be
less than 2p-1
at least for some
values. Here, p
is equal to 24 for 32-bit precision and 53 for
64-bit precision. To determine the precision, the defect uses your specification for
Target processor type (-target)
.
This defect appears only if one operand is always negligibly smaller than the other operand. To see instances of subnormal operands or results, use the check Subnormal Float in Polyspace® Code Prover™.
Examples
Result Information
Group: Numerical |
Language: C | C++ |
Default: On |
Command-Line Syntax: FLOAT_ABSORPTION |
Impact: High |
Version History
Introduced in R2016bSee Also
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)