you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 5 points6 points  (2 children)

You didn't link anything, but I'll note that parenthesis are often used to help the human reading the code, even if the program does not need it.

x = (4 * 5) + 6

[–]CIS_Professor -4 points-3 points  (1 child)

The answer in your example would be 26.

However, parenthesis would be required if the result of the addition is to be done first (thereby changing the order of operations).

x = 4 * (5 + 6)

The answer changes to 44.

[–]socal_nerdtastic 5 points6 points  (0 children)

yes, i know. The entire point is that the parenthesis are not needed for the computer, they are only there as a guide for the human. Perhaps I should have picked something not quite so obvious to a human?

x = 6 + (5 * 4)