Division by Zero questions?

Dr. Megabyte megabyte at chinet.UUCP
Fri Nov 14 07:16:26 AEST 1986


The following questions relate to the following short "C" program:

main()
{
        float x;
        float y;

        y = 0;
        x = 5/y;
        printf("%f \n",x);
}

On my AT&T 3b2/400 with SYS V R2.04, the program dumps core at the line with
the division and prints the message:"Floating Point Exception - Core dumped".
This seemed reasonable to me. The I tried the same program on my Zilog Model
31 running Zeus 3.21, which is a SYS III port and the program did NOT dump
core. When it got to the printf statement it printed "INF" Which I assume
must mean "Is Not Float". I can find no documentation on this, though if I 
change the floats above to ints, the Zilog prints "NAN" as the result.

Now, I feel the AT&T is doing the correct thing. The question is what in the
world is my Zilog doing, and where do those "NAN" and "INF" messages come from
on the printf statements.

Reply by e-mail or to the net as appropriate

The opinions expressed herein are my own and do not reflect those of 
the Internal Revenue Service or any other agency of the United States
Government. (A US Gov't disclaimer designed to protect the taxpayers 
from their fellow taxpayers)
-- 
UUCP:	(1) seismo!why_not!scsnet!sunder		Mark E. Sunderlin
	(2) ihnp4!chinet!megabyte			aka Dr. Megabyte
CIS:	74026,3235					(202) 634-2529
Mail:	IRS  PM:PFR:D:NO  1111 Constitution Ave. NW  Washington,DC 20224  



More information about the Comp.unix.questions mailing list