comparing double values in C++

后端 未结 1 637
终归单人心
终归单人心 2021-02-11 06:07

I have following code for double comparision. Why I am getting not equal when I execute?

#include 
#include 
#include          


        
相关标签:
1条回答
  • 2021-02-11 06:36

    The epsilon for 2 doubles is 2.22045e-016

    By definition, epsilon is the difference between 1 and the smallest value greater than 1 that is representable for the data type.

    These differ by more than that and hence, it returns false

    (Reference)

    0 讨论(0)
提交回复
热议问题