Xref: utzoo comp.lang.fortran:5360 comp.unix.aix:5032 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!gatech!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.fortran,comp.unix.aix Subject: Re: HELP! Need Decent RS6000 Fortran Compiler! Message-ID: <3502@charon.cwi.nl> Date: 11 May 91 13:28:40 GMT References: <1991May9.015512.27264@murdoch.acc.Virginia.EDU> Sender: news@cwi.nl Followup-To: comp.lang.fortran Organization: CWI, Amsterdam Lines: 35 In article jkorpela@vipunen.hut.fi (Jukka Korpela) writes: > - peculiarly, if you want to test within a program whether the value > of X is NaN, X.NE.X seems to be the (undocumented) way; there are > probably ways of detecting infinities as well This is perfectly documented in the IEEE standard on floating point arithmetic! To test for infinities try: (X-X).NE.(X-X) (if X is an infinity, X-X is a NaN.) another way: (1.0/X).EQ.0.0 > - using the (documented, but poorly documented) routines FPGETS and > FPSETS you can detect if floating-point errors have occurred They probably extract the sticky IEEE flags. > - but you probably can't really trap them; even in C, you can't use > the standardized tools; I tried to trap SIGFPE and the result is > that a) 1.0/0.0 doesn't generate a trap, it simply produces INF, > b) if I call fp_enable_all, 1.0/0.0 still doesn't generate a trap, > but it produces 1.0 !!! That is definitely a bug. But you really do not want to trap them in the RS6000. According to my literature it is possible at the hardware level, but it implies that all F-P operations will be serialized, which costs you a lot of performance. > - errors in math routines (well, actually, more or less invalid args to > them, like SQRT(-1.0) or EXP(1E30)) do not necessarily (usually?) set > FPE flags on (understandable), so you can't use FPGETS to see if they; > you CAN use matherr, but it's designed to be C callable, so you need > a simple interface routine SQRT must set the sticky bits according to IEEE. IEEE does not talk about EXP, but a honest implementation would also correctly set the bits. -- dik t. winter, cwi, amsterdam, nederland dik@cwi.nl