This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]