Floating point implementations

serge serge at pacific.UUCP
Thu Jan 9 11:09:53 AEST 1986


Is there some sort of standard in unix or IEEE for how to deal with the 
following floating point issues.  If there is no standard, what is the 
"preferred" action?  I am especially interested in how 68000-based 
systems behave, but would also be interested in knowing how other Unix 
systems deal with it.

		double a, b, c;
		  [assignment to b and c] 
		c = a / b;

	1) If `a' == 1.0 and `b' == 0.0 , should the divide-by-zero cause 
	   a SIGFPE?  (on some Unix systems it does not).  If a signal 
	   should not be generated, then what value should be
	   assigned to `c'?

	2) If SIGFPE is being ignored or caught (perhaps there are two
	   answers), what value should be assigned to `c'?  I suppose the 
	   possibilities are infinity, a NaN, or some random value since 
	   one could claim that dividing by zero produces an undefined result.

	3) If `a' and `b' above both contain infinity, then what should
	   happen (infinity divided by infinity is a Nan)?  Should SIGFPE
	   be generated in this case?  What if it is ignored or caught?

	4) If you manage to get the value of infinity or a nan into a
	   a float or double variable, what should printf(3) do with it
	   if you pass this value to it?  I have seen various Unix systems
	   deal with this in one of three ways:
		a) generate a SIGFPE
		b) print a large number (for infinity)
		c) go into an infinite loop (usually in ecvt(3))

Please respond by E-mail and I will post a summary if there is enough
interest.  I apologize if this has all been discussed before (if it
has, would someone please let me know what, if anything, was decided). 

	Thanks!

	Serge Issakow
-- 

	sdcsvax  \
	          >!pacific!serge
	s3sun    /



More information about the Comp.lang.c mailing list