Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Power operator? Message-ID: <10088@mimsy.UUCP> Date: 8 Jan 88 02:05:35 GMT References: <47000029@uxe.cso.uiuc.edu> <10063@mimsy.UUCP> <646@l.cc.purdue.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 57 >In article <10063@mimsy.UUCP> I wrote: >> a = pow(x, 7.); >>Unless you write `#undef pow' after `#include ', you may >>get in line code (fpushf (fp-4); fftod; fpushd $0d7.0; fexpd etc). In article <646@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >I think everyone should consider this unsatisfactory. > >One reason is that requiring the writing of a subroutine call is that >this requires people to use that notation . . . . This is indeed an annoyance, as there is no way to define a shorthand version. Writing `x = plus(y, z)' instead of `x = y + z' is less familiar. On the other hand, I know of no language that lets me write 4 3 x a = ------------------ 2 (b - c/7) (k - x) as a statement. I do not believe this is a serious problem, just as I do not believe that `:=' is particularly better or worse than `=' for assignment. It is just different. (Well, `:=' requires shift-unshift, and the two keys are under the same finger for touch typists, which is bad.) >Similar thinking would require one to write x = sub(y, z) instead of >x = y - z. This is a major design flaw in all HLLs which I know. (One solution to the dichotomy between builtin operators and other functions is to eliminate all the builtin operators. I happen to LIKE this idea.) >Another is that there are _several_ power functions; the one in >the standard math library is the slowest one.... [at worst] if it >is known that the 7 is an integer the resulting code will run at >least an order of magnitude faster than the pow function. What pow function? Who said we were calling the pow function? :-) *You* see `pow'; the compiler sees `_builtin_pow', as defined in . _builtin_pow can be arbitrarily fancy, including testing its second argument to see whether it is an integral value. You might get this inline code instead: fpushf (fp-4) # x fdupf fsquaref # pow(x,2) fdupf fsquaref # pow(x,4) faddf # pow(x,6) faddf # pow(x,7) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris