floating point precision in the c++ standard?
Hi,
In "C++ Primer, fourth edition" I read the following:
"The float type is usually not precise enough for real programs - float is guaranteed to offer only 6 significant digits. The double type guarantees at least 10 significant digits, which is sufficient for most calculations." (2.1.2. Floating-Point Types, page 37)
Isn't the number of significant digits implementation defined?
Quote:Original post by crocomireYes, but there are probably lower limits too as with the integer types.
Isn't the number of significant digits implementation defined?
I don't know for sure though..
They are implementaiton defined, but the C and C++ standards require minimum values for floating point constants. FLT_DIG is minimally 6, and implementation may have a floating point representation greater than 6. Similarly DBL_DIG is minimally 10.
Quote:Original post by SiCrane
They are implementaiton defined, but the C and C++ standards require minimum values for floating point constants. FLT_DIG is minimally 6, and implementation may have a floating point representation greater than 6. Similarly DBL_DIG is minimally 10.
Ok, so these requirements on floating point constants imply the same requirements on floating point types (e.g. variables)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement