...
Ordinarily all of the mantissa bits are used to express significant figures, in addition to a leading 1, which is implied and, therefore, left out. Thus, floats ordinarily have 24 significant bits of precision, and doubles ordinarily have 53 significant bits of precision. Such numbers are called normalized numbers. All floating point numbers are limited in this sense that they have fixed precision. See guideline recommendation FLP00-C. Understand the limitations of floating point numbers.
Mantissa bits are used to express extremely small numbers that are too small to encode normally because of the lack of available exponent bits. Using mantissa bits extends the possible range of exponents. Because these bits no longer function as significant bits of precision, the total precision of extremely small numbers is less than usual. Such numbers are called denormalized, and they are more limited than normalized numbers. However, even using normalized numbers where precision is required can pose a risk. See guideline recommendation FLP02-C. Avoid using floating point numbers when precise computation is needed for more information.
...
If using doubles also produces denormalized numbers, using long doubles my or may not help. (on some implementations, long double has the same exponent range as double.) If using long doubles produces denormalized numbers, some other solution must be found.
Printing
...
Denormalized Numbers
Denormalized numbers can also be troublesome because some functions have implementation defined behavior when used with denormalized values. For example, using the %a or $%A conversion specifier in a format string can produce implementation defined results when applied to denormalized numbers.
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
Bibliography
Wiki Markup |
---|
\[[IEEE 754|AA. Bibliography#IEEE 754 2006]\]
\[[Bryant 2003|AA. Bibliography#Bryant 03]\] Computer Systems: A Programmer's Perspective. Section 2.4 Floating Point
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] |
...
FLP04-C. Check floating point inputs for exceptional values 05. Floating Point (FLP) FLP30-C. Do not use floating point variables as loop counters