Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.c Subject: Re: Power proposal for ANSI C Keywords: power exponentiation ** Message-ID: <7487@boring.cwi.nl> Date: 10 Jan 88 08:16:14 GMT References: <38384@sun.uucp> Organization: CWI, Amsterdam Lines: 26 In article <38384@sun.uucp> dgh%dgh@Sun.COM (David Hough) writes: > Recommendation: Add a power operator **, with the > -------------- > precedence of a cast operator, so that a cast expression can > be > > cast-expression ** cast-expression > > In b ** n, the base expression b may be an integral or > floating expression, but the exponent expression n must be > an integral expression. If n == 0, then the result is 1 > cast to the type of b. If n > 0, then the result is the usual: > the value of b is multiplied together n-1 times. If n < 0, > then the result is the reciprocal of b ** (-n), which is 0 > if b is an integral expression >= 2. Note that these semantics are wrong. What if n<0 and b**(-n) overflows while b**n does not underflow? According to the stated semantics this should trap an overflow or return 0.0. On the other hand if b**n for negative n is defined as (1/b)**(-n) we lose precision. So is there anybody who can come up with a proper definition of the power operator? -- dik t. winter, cwi, amsterdam, nederland INTERNET : dik@cwi.nl BITNET/EARN: dik@mcvax