Jump to content
  • Advertisement
Sign in to follow this  
crocomire

floating point precision in the c++ standard?

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by crocomire
Isn't the number of significant digits implementation defined?
Yes, but there are probably lower limits too as with the integer types.
I don't know for sure though..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!