Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704A-Liber) Newsgroups: comp.lang.c Subject: Re: Power proposal for ANSI C Keywords: power exponentiation ** Message-ID: <3421@ihlpf.ATT.COM> Date: 19 Jan 88 02:47:24 GMT References: <38384@sun.uucp> <2252@haddock.ISC.COM> Reply-To: nevin1@ihlpf.UUCP (00704A-Liber,N.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 40 In article <2252@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) writes: > >mean the "wrong" thing. If this is a problem (apparently bc users don't >mind), my recommendation is to give it a precedence between postfix unary and >prefix unary. (Note that "->id", ".id", "[expr]", and "(arglist)" can all be >considered postfix unary, just as "(type)" can be considered prefix unary.) >More precisely: > >power-expression: > postfix-expression > postfix-expression *^ cast-expression > >unary-expression: > power-expression > ++ unary-expression > -- unary-expression What about 'unary-expression ++'? Currently, this is on the same level as pre-incrementing with the distinction being associativity. Would you split these two and put power between them? Also, what would the associativity be for power? Would 2 *^3 *^5 be equal to 2 *^ 15 or to 2 *^ 243? >I think 2 *^ -1 should be undefined (as is 1 << -1), rather than zero. Since we are defining the 'power' operator and not the 'integer power' operator, 2 *^ (-1) should return (double)0.5 and then be demoted to an integer class, if necessary. The power operator should not return two different numbers (other than with respect to precision) based on the types of the arguments. This is one of the major reasons I don't like the intro of the power operator into C. (BTW, maybe ANSI should define (1 << -1) as right-shifting by 1--any response to this out there?) Your example (2 *^-1, no parentheses around -1) is undefined because of the way you defined your precedence; i.e., 2 *^ -1 groups as (2 *^ -) 1 (sort of). -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_