+ 4
Relating to compound operaters
does j+=a-b mean j=j+(a-b) or j=j+a-b
3 odpowiedzi
+ 13
yes , case1 is true
//still to eliminate any confusion in it , it is suggested to make use of brackets ()
+ 1
j += a-b is both. due to the nature of addition, both are the same, so it doesn't matter. ;P
But 'underneath the hood', Faisal is correct: it is j = j + (a - b). you can test that by testing j *= a - b, which does make a difference. u can see that it is j = j * (a - b). warning: i have not tested this so you need to assume we are all wrong until you test it yourself. ;P (But i have been a programmer for about 30 years.)
0
i recommend against using parentheses like j += (a + b). it shows that u r an utter newbie, especially when the order does not matter. and it's just useless wasted extra symbols. in other words, using j += (a + b) is like using j = j + (a + b) when j = j + a + b is just the same *except easier to read*.