Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM Cost Reform

The C programming language provides the ability to use floating-point numbers for calculations. The C Standard specifies requirements on a conforming implementation for floating-point numbers but makes few guarantees about the specific underlying floating-point representation because of the existence of competing floating-point systems.

...

On 64-bit Linux, with GCC compiler 4.1, it produces

Code Block
Float is 0.33333334326744079589843750000000000000000000000000

...

When compiled on an IA-32 Linux machine with GCC compiler 3.4.4 at optimization level 1 or higher, or on an IA-64 Windows machine with Microsoft Visual Studio 2012 in Debug or Release mode, this code prints

...

On an IA-32 Linux machine with GCC compiler 3.4.4 with optimization turned off, this code prints

...

Failing to understand the limitations of floating-point numbers can result in unexpected computational results and exceptional conditions, possibly resulting in a violation of data integrity.

Recommendation

Severity

Likelihood

Remediation Cost

Detectable

Repairable

Priority

Level

FLP00-C

Medium

Probable

No

High

No

P4

L3

Automated Detection

Tool

Version

Checker

Description

CodeSonar

Include Page
CodeSonar_V
CodeSonar_V

LANG.ARITH.FMULOFLOW
LANG.ARITH.FPEQUAL
Float multiplication overflow
Floating point equality
ECLAIR
Include Page
ECLAIR_V
ECLAIR_V
floateqlFully implemented
CC2.FLP00Fully implemented
Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C0275, C0581, C1490, C3339,
C3340, C3341, C3342, C3362


Parasoft C/C++test
Include Page
Parasoft_V
Parasoft_V

CERT_C-FLP00-a

Floating-point expressions shall not be tested for equality or inequality
PC-lint Plus

Include Page
PC-lint Plus_V
PC-lint Plus_V

777, 9252

Partially supported

Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C: Rec. FLP00-CChecks for absorption of float operand (rec. partially covered)

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this recommendation on the CERT website.

Related Guidelines


Bibliography

[Gough 2005]Section 8.6, "Floating-Point Issues"
[
IEEE 754 2006] [
Hatton 1995]Section 2.7.3, "Floating-Point Misbehavior"
[IEEE 754 2006]
[Lockheed Martin 2005]AV Rule 202, Floating-point variables shall not be tested for exact equality or inequality

...


...

Image Modified Image Modified Image Modified