home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: Power Operator vs NANs
- Message-ID: <TMB.92Jul21152204@arolla.idiap.ch>
- Date: 21 Jul 92 19:22:04 GMT
- References: <BqJ16w.n3J@world.std.com> <1992Jun28.094255.13827@ucc.su.OZ.AU>
- <BqM2JG.8Ds@news.cso.uiuc.edu> <1992Jun29.144814.5240@u.washington.edu>
- <819@nazgul.UUCP> <1992Jul15.123527.3771@bnr.co.uk> <850@nazgul.UUCP>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 44
- In-reply-to: bright@nazgul.UUCP's message of 20 Jul 92 18:18:48 GMT
-
- In article <850@nazgul.UUCP> bright@nazgul.UUCP (Walter Bright) writes:
-
- C++ has abandoned ones-complement hardware and 6-char linkers, that C
- was unwilling to leave behind. Maybe it is time to leave behind non-IEEE
- floating point too.
-
- C++ does not specify how integer arithmetic is to be performed on the
- machine. And, personally, I don't think it's time to leave behind
- non-IEEE floating point.
-
- /Exactly what would a language extension give you that you couldn't do using
- /(FPU specific) function calls?
-
- What you gain with a language extension vs function calls:
- 1. syntactic clarity
- 2. portability (assuming others implement it too)
- 3. compiler can detect errors
- 4. static initialization
- 5. efficiency
-
- There is a nice middle road. You can use functional/macro syntax
- (isnan(x), isinf(x), ...) to denote standardized IEEE floating point
- operations. Such notation is straighforward, simple, and easy to
- implement even in existing compilers. Via the usual "#define foo(x)
- __foo(x)" trick, you can get macro semantics (i.e., you don't get the
- feature unless you #include the header file) with the efficiency and
- flexibility of a language extension.
-
- For instance, only Zortech's compiler correctly (IEEE 754) implements
- == and != (others set the exception bits incorrectly if one operand
- is a NAN). Do you really want to do isequal(a,b) instead of a==b?
-
- I would want neither. The behavior of operator== on NaN's should be
- left undefined. If you care to know whether operator== is operating on
- a NaN, you should simply test beforehand:
-
- if(isnan(x)||isnan(y)) { ... }
- else if(x==y) { ... }
-
- Sadly, this is a losing battle. NCEG seems to be determined to go down
- this route of adding lots of IEEE specific, complicated, useless
- operators, and the C++ language is likely to follow suite.
-
- Thomas.
-