-float-rounding-mode)Specify rounding modes to consider when determining the results of floating point arithmetic
This option affects a Code Prover analysis only.
Specify the rounding modes to consider when determining the results of floating-point arithmetic.
User interface (desktop products only): In your project configuration, the option is available on the Verification Assumptions node.
Command line and options file: Use the option
-float-rounding-mode. See Command-Line Information.
The default verification uses the round-to-nearest mode.
Use the rounding mode all if your code contains routines such as
fesetround to specify a rounding mode other than
round-to-nearest. Although the verification ignores the
fesetround specification, it considers
all rounding modes including the rounding mode
that you specified. Alternatively, for targets that can use extended precision (for
instance, using the flag -mfpmath=387), use the rounding mode
all. However, for your Polyspace® analysis results to agree with run-time behavior, you must prevent use
of extended precision through a flag such as
-ffloat-store.
Otherwise, continue to use the default rounding mode to-nearest.
Because all rounding modes are considered
when you specify all, you can have many
orange Overflow checks resulting from overapproximation.
Default: to-nearest
to-nearest The verification assumes the round-to-nearest mode.
all The verification assumes all rounding modes for each operation involving floating-point variables. The following rounding modes are considered: round-to-nearest, round-towards-zero, round-towards-positive-infinity, and round-towards-negative-infinity.
The Polyspace analysis uses floating-point arithmetic
that conforms to the IEEE® 754 standard. For instance, the arithmetic
uses floating point instructions present in the SSE instruction set.
The GNU® C flag -mfpmath=sse enforces use of
this instruction set. If you use the GNU C compiler with this
flag to compile your code, your Polyspace analysis results agree
with your run-time behavior.
However, if your code uses extended precision, for instance using the GNU C flag -mfpmath=387, your Polyspace analysis results might not agree with your run-time behavior in
some corner cases. See some examples of these corner cases in
codeprover_limitations.pdf in
.
Here, polyspaceroot\polyspace\verifier\code_prover_desktop is the
Polyspace installation folder, for instance, polyspacerootC:\Program
Files\Polyspace\R2019a.
To prevent use of extended precision, on targets without SSE
support, you can use a flag such as -ffloat-store.
For your Polyspace analysis, use all for rounding
mode to account for double rounding.
The Overflow check uses the rounding modes that you specify. For instance, the following table shows the difference in the result of the check when you change your rounding modes.
Rounding mode: to-nearest | Rounding mode: all | ||
|---|---|---|---|
If results of floating-point operations are rounded to nearest values:
| Besides to-nearest mode, the Overflow check also considers other rounding modes.
|
If you set the rounding mode to all and
obtain an orange Overflow check, to determine
how the overflow can occur, consider all
rounding modes.
Parameter: -float-rounding-mode |
Value: to-nearest | all |
Default: to-nearest |
Example (Code Prover): polyspace-code-prover
-sources |
Example (Code Prover
Server):
polyspace-code-prover-server -sources
|