Path: utzoo!mnetor!uunet!husc6!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.lang.c Subject: Re: Power operator? Message-ID: <2659@mmintl.UUCP> Date: 18 Jan 88 23:02:55 GMT References: <11169@brl-adm.ARPA> <10026@ut-sally.UUCP> <553@gethen.UUCP> <2516@dasys1.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT. Lines: 25 In article <2516@dasys1.UUCP> wfp@dasys1.UUCP (William Phillips) writes: >I'm implementing a compiler for a special purpose language that looks a lot >like C. The language spec that I was given specifies that the << and >> >operators, when applied to floating point objects, act as exponentiation >and inverse exponentiation operators; a logical sort of extension of >right and left shifts of integer objects, isnt it? No, it isn't. Besides the fact that under this interpretation 3 << 3 means something *entirely* different from 3.0 << 3, there is the fact that I want to raise integers to powers, too, not just floats. In fact, I believe that the single most common use of exponentiation, in languages which have operators for it, is to square an integer. (This is based only on my intuition, and obviously varies depending on the nature of the application.) If I were to apply a meaning to 3.0 << 3, it would be "3.0 times 2 to the third", or 24.0. Note that this is a function which many machines can implement with simple in-line code. -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108