Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!bruce.cs.monash.edu.au!merlin!mel.dit.csiro.au!its.csiro.au!dmssyd.syd.dms.CSIRO.AU!metro!ultima!kralizec.zeta.org.au!godzilla.zeta.org.au!not-for-mail From: bde@kralizec.zeta.org.au (Bruce Evans) Newsgroups: comp.os.386bsd.questions Subject: Re: sqrt(-1) Date: 8 Mar 1994 06:33:12 +1100 Organization: Kralizec Dialup Unix Sydney - +61-2-837-1183, v.32bis and v.42bis Lines: 29 Message-ID: <2lfvhoINN3f3@godzilla.zeta.org.au> References: <762584248.AA09532@f74.n700.z6.ftn.air.org> <2l1nt3$m0s@Germany.EU.net> <CM1wLn.Gvs@nas.nasa.gov> NNTP-Posting-Host: godzilla.zeta.org.au In article <CM1wLn.Gvs@nas.nasa.gov>, Dave Tweten <tweten@wilbur.nas.nasa.gov> wrote: >In article <2l1nt3$m0s@Germany.EU.net> bs@Germany.EU.net (Bernard Steiner) writes: > >>I assume that -O2 switches on -ffast-math that inlines many of the >>library calls to __asm__s. Maybe you can switch it of with -fno-fast-math >>or something. > >Actually, some of the math routines were written by someone who thought >a good way to report a mathematically impossible calculation (eg., >log(0)) was to return a constant expression which involved dividing by >zero. Actually, someone was trying to set the IEEE illegal operation flag and return an IEEE NaN semi-portably. The C standard does not support IEEE stuff or NaNs, but zero/zero is a good try and ought to work on systems that support IEEE floating point. "-O2" does compile-time constant expression evaluation. Perhaps it shouldn't when evaluating the expression causes an (IEEE) exception. On IEEE systems where zero/zero doesn't trap, gcc -O2 evaluates zero/zero at compile time as a NaN. This differs from the result of evaluating it at runtime (the invalid operation exception doesn't get raised), so it is a low quality optimization. Declaring `zero' as volatile is sufficent to defeat the optimization. -- Bruce Evans bde@kralizec.zeta.org.au