好库网首页 | 我的好库
好库网 好库网社区
IT社区 » C/C++ » C语言论坛 » C programming: comparing double with 0.0
回复 发帖

查看:32    回复:0 C programming: comparing double with 0.0
访问depprussell的空间
发表于 2018/6/20 11:33:08
1楼

Hello,

 

I have code that uses variables of type double. Those are explicitly initialized with 0.0.
Later in the code, I want to see if they are still zero. I am aware of binary approximation issues with floating point numbers, and I have a function that is able to compensate for those within the limits of precision needed. However, I would prefer not to use the function when I compare the variable against 0.0, for performance reasons. Weak argument, but please let me run with it. Is my assumption correct that the value 0.0 has a precise binary representation that can be compared against with the == and != operators?

 

Please help

 

I didn't find the right solution from the internet.

 

References:

https://arstechnica.com/civis/viewtopic.php?f=20&t=375458

Startup video production service

 

Thank you

 

您需要登录后才可以回帖 登录 | 注册
回复 发帖