Jump to content
  • Advertisement
Sign in to follow this  
anist

Comparing doubles to 0

This topic is 4796 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

I know this is a big no no with floats because of precision, but do doubles overcome this? i am doing some code review of some really horrible code and am dealing with this: if( point.x == 0.0 && point.y == 0.0 && point.z == 0.0) // do this there are many errors and a total lack of coding standars this jackass delivered to me, so it matters little but for my own personal peace of mind i'd like to know.

Share this post


Link to post
Share on other sites
Advertisement
doubles have the most of the same problems floats have, they are just alot
more tolerant. you should always use an epsilon value to compare floats/doubles.

Share this post


Link to post
Share on other sites
Sorry, I'm afraid that using doubles doesn't magically solve the inability to accurately represtent certain values like 0.1, or the inaccuracy that comes accumulates when performing calculations.

If point is the result of some calculation, then you still need to compare them using an epsilon value, however the epsilon value can be significantly smaller, by many orders of magnitude in fact.

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!