| ▲ | Groxx 2 hours ago | |
Non-mixed always goes strictly left to right, regardless of the operator, which I haven't seen anywhere near as much struggling with. But yes, I personally parenthesize `a-b-c` explicitly, because it's not worth it for me to read and wonder if parenthesizing order matters later. Costs less than a second to write, saves a second or ten each time I read it - that's an excellent tradeoff imo, and is a trivial pattern to follow. (Associative operators are fine, obviously) | ||
| ▲ | simonreiff an hour ago | parent [-] | |
I agree with explicit parentheses but please be careful about assuming associativity! The risk when handling floating-point arithmetic in particular is that associativity breaks, and suddenly a + (b + c) does NOT equal (a + b) + c. Not only can these lead to unexpected and hard-to-trace failure patterns, but depending on the details, they also can introduce memory overflow/underflow vulnerabilities. | ||