3 ms·
That's the exact same thing that repiret said, I think. I think power (^) has higher precedence than subtract (-). So (2^32-1)/10000 == ((2^32)-1)/10000 Wolf
by Thorrez 6y ago
That's the exact same thing that repiret said, I think.
I think power (^) has higher precedence than subtract (-).
So (2^32-1)/10000 == ((2^32)-1)/10000
WolframAlpha agrees: https://www.wolframalpha.com/input/?i=%282%5E32-1%29%2F10000+%3D%3D+%28%282%5E32%29-1%29%2F10000 https://www.wolframalpha.com/input/?i=%282%5E32-1%29%2F10000...
- Uptrenda 6y agoHonestly, I always found precedence rules horribly ambiguous. I just use brackets for clarity and forget about it. Or is this considered 'bad practice'?
- LorenPechtel 6y agoI've never found it to be an issue with math. Unary minus > powers > multiplication/division > addition/subtraction. I have seen differences in the precedence of logical operators between languages (and > or but what happens when you have both math and logic in the same statement isn't entirely consistent) and always use parenthesis in those cases--although these days if Resharper says it's redundant I let it remove them.
- Thorrez 6y agoI don't consider it bad practice to insert parentheses, especially with exponentiation because many people are less familiar with its precedence rules.