Pow operator precedence

Nick Sabalausky a at a.a
Fri Jan 13 13:09:15 PST 2012


"Manu" <turkeyman at gmail.com> wrote in message 
news:mailman.328.1326483521.16222.digitalmars-d at puremagic.com...
On 13 January 2012 21:24, Grue <Grue at nop.com> wrote:
>>
>> Beware... your statement has awoken an "Ancient Forum Lurker"! ;)
>>
>
>Sweet! I have that effect :P

Arise!

>In my prior post I agreed, though that said, I still maintain that none of
>those exampled look sufficiently like -5 ^^ 2 by my mind to be considered
>'the same thing'. The single ^ and your not using spaces on either side
>distinguish it quite clearly...

If that's the case, then what you're objecting to is almost exactly like:

2+3 * 4+1

But that's well-accepted. If the spaces throw you off, then just use them 
differently:

2 + 3*4 + 1
-5^^2

>It's funny, I've written a lot of maths code (mostly physics and/or
>rendering/lighting), but I can probably count the number of times I've used
>pow() on one hand. I use sqrt(), but I think that's a fairly well
>established subset of pow(), and people would never use ^^ to perform a
>sqrt. A function of that rarity possibly doesn't warrant a custom operator
>:)

Sounds like you're talking about game code, in which case it doesn't 
surprise me you haven't used it much. Game code needs to be real-time, so 
doing advanced math in code tends to be avoided whenever possible, even if 
it's at the expense of slight inaccuracy (since framerate and user 
experience are more important than perfect mathematical "correctness"). 
Other applications would be fairly different, like scientific computing.




More information about the Digitalmars-d mailing list