[Bug c/15437] int vs const int computation: different answers

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Sat May 15 15:50:00 GMT 2004


------- Additional Comments From bangerth at dealii dot org  2004-05-14 20:28 -------
Well, if they are integers that happen to be represented as doubles, 
then you should use round(), and not the truncating conversion to int(). 
The general idea of comparing doubles by converting them to integers 
and then comparing is wrong. Comparing floating point values always 
has to be done using floating point arithmetic and making sure that 
the difference is less than some epsilon. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15437



More information about the Gcc-bugs mailing list