Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 5/23/85; site pacific.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!s3sun!pacific!serge From: serge@pacific.UUCP (serge) Newsgroups: net.lang.c,net.unix,net.unix-wizards,net.micro.68k Subject: Floating point implementations Message-ID: <1022@pacific.UUCP> Date: Wed, 8-Jan-86 20:09:53 EST Article-I.D.: pacific.1022 Posted: Wed Jan 8 20:09:53 1986 Date-Received: Sat, 11-Jan-86 05:52:53 EST Organization: Pacific Microcomputers, San Diego CA Lines: 45 Xref: linus net.lang.c:6996 net.unix:6234 net.unix-wizards:13510 net.micro.68k:1373 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 /