home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!van-bc!nwnexus!ole!rwing!fnx!nazgul!bright
- From: bright@nazgul.UUCP (Walter Bright)
- Newsgroups: comp.lang.c++
- Subject: Re: Power operator! for C++
- Message-ID: <848@nazgul.UUCP>
- Date: 20 Jul 92 17:49:10 GMT
- References: <1992Jun29.062858.7308@lth.se> <1992Jun29.161922.4263@ucc.su.OZ.AU> <820@nazgul.UUCP> <1992Jul15.033910.5300@actrix.gen.nz>
- Reply-To: bright@nazgul.UUCP (Walter Bright)
- Organization: Zortech, Seattle
- Lines: 33
-
- In article <1992Jul15.033910.5300@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes:
- /In article <820@nazgul.UUCP> bright@nazgul.UUCP (Walter Bright) writes:
- /> Zortech C/C++ is the only compiler so far that has stable and robust behavior
- /> regarding NANs and infinities. All the library functions dealing with floating
- /> point now have defined behavior with all the different IEEE special cases.
- /> The compiler itself can handle NANs, such as:
- /> static double d = NAN;
- /Zortech is great, Walter (on the PC anyway), but what's wrong with
- /this from MPW C++?
- /
- /#include <iostream.h>
- /void main(){
- / cout << "3/0 gives " << 3.0/0.0 << ", 0/0 gives " << 0.0/0.0;
- /};
- /buildprogram test >dev:null
- /test
- /3/0 gives INF, 0/0 gives NAN(004)
-
- There is nothing at all wrong with it. It is simply not enough. 0.0/0.0 as
- a substitute for NAN has the non-portable deficiency of how the compiler handles
- exceptions when constant folding. NCEG defines all these behaviors, and
- offers things like isnan(double), and a long list of other things.
- Lots of compiler printf's cannot handle NANs, for instance, check out C7's
- library reference on what happens if you pass a NAN for a double:
- digit.#NANrandom-digits
- (I am not kidding...) Some printf's will hang or crash if you pass NAN
- or INFINITY.
-
- I'd rather program NAN than 0.0/0.0, and likewise for INFINITY.
- All the library functions should be able to handle these special values.
-
- Some of what NCEG does is simply to nail down the behavior instead of leaving
- it undefined like ANSI C does.
-