Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: power operator Message-ID: <2197@haddock.ISC.COM> Date: 9 Jan 88 04:58:51 GMT References: <11182@brl-adm.ARPA> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 25 In article <11182@brl-adm.ARPA> V4039%TEMPLEVM.BITNET@CUNYVM.CUNY.EDU (Stan Horwitz) writes: >Gus Baird suggest's that C might not have been given a power operator so as >to make the point (to programming students) that some operators such as >the power operator require some overhead. It wasn't done for the benefit of students, but yes, my understanding is that the authors did intentionally avoid having nontrivial semantics on the builtin operators. (They could have done it anyway, and justified it by saying that the most common cases have a small positive integer constant as the right operand; this case is sufficiently simple to be a builtin.) Actually, I'd give a higher wish-priority to min and max operators. They could have used "><" and "<>", respectively; the syntax would drive BASIC and PASCAL users crazy! :-) >If C can have an operator for such as % for modulo divide, why not one for >exponentiation? Surely the same arguments against such a request can also be >made against the inclusion of %. "%" is a single instruction on the pdp11 (it's a side effect of doing a divide in the proper registers). On most other architectures, it's still only a divide-multiply-subtract. Exponentiation isn't that simple; in general, it requires a loop. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint