This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/15437] int vs const int computation: different answers
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 May 2004 20:28:22 -0000
- Subject: [Bug c/15437] int vs const int computation: different answers
- References: <20040514162247.15437.lani@oas.ca>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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