Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!bloom-beacon!primerd!hobbiton!fieland From: fieland@hobbiton.prime.com Newsgroups: comp.lang.c Subject: Re: floating point constants Message-ID: <192700001@hobbiton> Date: 27 Jul 89 15:08:00 GMT References: <1925@arisia.Xerox.COM> Lines: 33 Nf-ID: #R:arisia.Xerox.COM:-192500:hobbiton:192700001:000:573 Nf-From: hobbiton.prime.com!fieland Jul 27 11:08:00 1989 According to K. & R., if the second operand of the division operator is zero, the result is undefined. Therefore, the compiler is free to do what it wants with this. On a more practical note, the following program will cause the sun 386i cc compiler to print out Inf, -Inf, and -Nan: (sic) /* This should print out inf -inf NaN */ main() {float f1, f2, f3, f4 = 0; f1 = 1.0/f4; f2 = -1.0/f4; f3 = 0.0/f4; printf("%f\n",f1); printf("%f\n", f2); printf("%f\n", f3); } Peggy Fieland fieland@primerd.prime.com