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:05 -------
Subject: Re:  int vs const int computation: different answers

I guess the only point we're trying to make is that using a different data
structure for const int as opposed to int is a bad idea. Whatever the rounding
issues, they would at least be consistent had things been done the same way in
both cases. I agree with you, though, that the double case is flaky anyway. The
issue, in that particular example, was to do with the consistency.

Example:

We used a const int to compute the height of a 2d array originally (using the
multiply by a double, which is a percentage of the height). Now we want
to read the height in as a command-line argument (as an int) and compare the
two to determine if the read in height will be compatible with previously
stored results. Whether or not the height computation is rounded to the "most
correct" numeric value doesn't matter to us, since it doesn't affect what we
are doing with the 2d array (i.e - it's just a general ballpark
value). However, since the computations were done inconsistently, they are now
incomparable. It doesn't make sense, then, that we should have to play all
sorts of games to try and fake one computation to produce the results of the
other when, in theory, there should be no difference in the two
representations. They are both "int" and should be treated the same way.

bangerth at dealii dot org writes :
> 
> 
> ------- Additional Comments From bangerth at dealii dot org  2004-05-14 18:24 -------
> I think the general answer here is that converting doubles to integers 
> is not a stable operation in the vicinity of the integer you expect. I 
> agree that this leads to a surprising result in your particular case, but 
> it would be just as easy to trigger with slightly more complex cases and 
> very hard to make the compiler stable against these kinds of things. 
>  
> 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]