Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!purdue!ames!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter From: walter@hpclwjm.HP.COM (Walter Murray) Newsgroups: comp.lang.c Subject: Re: floating point constants Message-ID: <660048@hpclwjm.HP.COM> Date: 27 Jul 89 19:13:38 GMT References: <1925@arisia.Xerox.COM> Organization: Hewlett-Packard Calif. Language Lab Lines: 25 >Is this a valid C program? gcc 1.35 handles it fine on a sun386i -- >everything else I've tried won't compile these odd constants. >/* This should print out > inf > -inf > NaN >*/ > >main() >{ > printf("%f\n", 1.0/0.0); > printf("%f\n", -1.0/0.0); > printf("%f\n", 0.0/0.0); >} In our compiler (HP 9000 Series 800) we evaluate these expressions at compile time, produce a warning, and store the appropriate bit patterns for +/- infinity and NaN. That seemed to be the thing to do to conform with the spirit of IEEE 754. Note, however, that there is no standard for what these numbers look like when formatted with "%f". Walter Murray ----------