[net.unix] C Quiz: why does this SIGFPE?

daveb@rtech.UUCP (Dave Brower) (04/12/86)

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