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


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