This is the mail archive of the gcc@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]

Re: GCC optimizes integer overflow: bug or feature?


But the same applies to floating point numbers. There, the situation is even better, because nowadays I can rely on a float or double being the representation defined in IEEE 754 because there is such overwhelming hardware support.

You better don't. Really! Please just realize for example the impact of the (in)famous 80 bit internal (over)precision of a
very common IEEE 754 implementation...


volatile float b = 1.;

if (1. / 3. == b / 3.) {
   printf("HALLO!\n")
} else {
   printf("SURPRISE SURPRISE!\n");
}

or just skim through http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323

However it's a quite common mistake to forget how "bad" floats "model" real numbers.

And it's quite a common mistake to forget how "bad" finite ints "model" integer numbers.

No it isn't. Most people don't think in terms of infinite arithmetics when programming.
And I hold up that the difference between finite and infinite is actually quite a fundamental
concept. However quite a lot of people expect the floating arithmetics rouding to give them
well behaved results.


Marcin Dalecki



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