Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When precise computation is necessary, use alternative representations that can accurately represent the values. For example, if you are performing arithmetic on decimal values and need an exact decimal rounding, represent the values in binary-coded decimal instead of using floating-point values. Another option is decimal floating-point arithmetic, as specified by ANSI/IEEE 754-2007. ISO/IEC WG14 has drafted a proposal to add support for decimal floating-point arithmetic to the C language [ISO/IEC DTR 24732].

...

This noncompliant code example takes the mean of 10 identical numbers and checks to see if the mean matches this number. It should because the ten 10 numbers are all 10.1. Yet, because of the imprecision of floating-point arithmetic, the computed mean does not match this number.

...

sectioncan

Can detect violations of this recommendation. In particular, it checks to see if the arguments to an equality operator are of a floating-point type.

Tool

Version

Checker

Description

Compass/ROSE

 

 

Section

Related Vulnerabilities

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

...

ISO/IEC TR 24772 "PLF Floating Point Arithmeticpoint arithmetic"

ISO/IEC DTR 24732

Bibliography

...