what is th eorder of presedents?
is 2 + 3 * 5 = 32 or 17
are you joking? The precedence is the same that you use in mathematical equations.
2 + 3 * 5 is the same that 2 + (3 * 5) = 17. If you want 32 you have to do: (2 + 3) * 5 = 32
lol..
(3+2) * 5 = 32... ( !!! ??? !!! ) very Lol.... Next time I will check the calc.. :)
Never-Ever leave it to the compiler to define precidence, regardless of IDE compliance to ANSI/other standards.
Always use Parenthisis to be (CLEAR) about what you be are doin' at.
--Cpt. Vince Foster 2nd Cannon Place Fort Marcy Park, VA
That sounds a bit too hard. The compiler do know the precendence rules, and the developer should know them too or have the access to the source code revoked.
Parentheses may be good for making the code faster to read in some situations, but I would not add parentheses for a three-argument equation with one add and one multiplication. No developer should need the parentheses for the readability.
But while parentheses may help with readability, too much parentheses makes the expression harder to read, forcing me to put the cursor on a parentesis just to see where the matching parenthesis is.
View all questions in Keil forum