A
Alexei A. Frounze
I have done one too.
It isn't.
You can write a correct C program that doesn't use floating point.
You can use a nonconforming C implementation
to translate and execute it.
q14.3 of the clc FAQ acknowledges that some implementations
of C, only link the math library as an option, not by default.
Btw, 20.6b to which refers 14.3 is wrong:
-----8<-----
For example, here is a ``careful'' addition function:
int
chkadd(int a, int b)
{
if(INT_MAX - b < a) {
fputs("int overflow\n", stderr);
return INT_MAX;
}
return a + b;
}
-----8<-----
How about b = -1, a = INT_MIN being inputs of this "carefully" adding
function?
The above looks like the implementation for unsigned addends that was
turned into signed addition w/o much or any thinking by simply
changing unsigned int's to int's and UINT_MAX to INT_MAX. The correct
implementation would be:
if (b >= 0)
{
if (INT_MAX - b < a)) {
fputs("int overflow\n", stderr);
return INT_MAX;
}
}
else
{
if (INT_MIN - b > a)) {
fputs("int overflow\n", stderr);
return INT_MIN;
}
}
return a + b;
Alex