home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11212 < prev    next >
Encoding:
Text File  |  1992-07-20  |  2.0 KB  |  45 lines

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