What is this unexplained result reason?

My question is, why da hell is the debugger giving me a different result
for this code:

1
2
3
4
5
6
7
int main() {

	int result1(2*7+3), result2(2+7*3); 
	std::cout<<(result1)<<std::endl
		<<(result2);

} //Obviously result1 computes to 17, but result2 computes to 23 and not 27, WTF?? 


is there a reason for why result2 gives a different answer?
Multiplication has higher precedence. Use parenthesis if you want 27 ie (2+7)*3
Last edited on
Topic archived. No new replies allowed.