C Quiz: why does this SIGFPE?
Dave Brower
daveb at rtech.UUCP
Sun Apr 13 02:33:22 AEST 1986
This is a quiz. The answer will be posted in a week or so. Don't
post a reply unless you need to impress your collegues.
Why will this code sometimes generate SIGFPE at the indicated point?
/* An example. Does nothing usefull */
int zerf( f )
float * f;
{
*f = 0.0;
return( (int)f );
}
void show( flag, i, f )
int flag, i; float f;
{
if(flag) printf( "i is %d\n", i )
else printf( "f is %f\n", f )
}
void dynomite( flag, i )
int flag, i;
{
float f;
if( flag ) i = zerf( &f );
else show( flag, i, f ); /* <-- SIGFPE happens here */
}
--
Red: "Whadda ya got that big nose for, granny?"
Wolf: "Just to HAVE, see!"
{amdahl, sun, mtxinu, cbosgd}!rtech!daveb
More information about the Comp.lang.c
mailing list