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: "lani at oas dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 May 2004 20:36:02 -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 lani at oas dot ca 2004-05-14 20:36 -------
Subject: Re: int vs const int computation: different answers
Hi,
If a compiler uses a banana to store an 'int',
it should use a banana to store a 'const int'
The const-ness should not affect the data, just the semantics.
I understand computers can't store floating point numbers perfectly.
I understand there are rounding issues. I understand comparisons have to be
done with care. My issue is not about any of those things. I understand on
one computer I might get '299', on another, get '300'. If I'm lazy, and don't
do it carefully, it's my fault.
But here we are not talking about doubles. We are talking about 'INT' vs
'CONST INT'. That's all.
Replacing an INT with a const int should ALWAYS give back the same answer.
In any computation. (The same answer that is, if compiled with the same
compiler on the same architecture). The rounding issues are beside the point.
I am not insisting doubles behave like ints or doubles behave identically
between compilers/architectures etc.
I am insisting 'INT' behaves like 'CONST INT'
bangerth at dealii dot org writes :
>
>
> ------- 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
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15437