numeric promotion
Posted: Thu Sep 09, 2021 7:44 am
Hello,
I have a question about this code example:
Why do we have a compiler time error?
Casting comes befor + operator, so I dont' understand why do we have int now.
I know, correct will be or due to numeric promotion;
I have a question about this code example:
Why do we have a compiler time error?
Casting comes befor + operator, so I dont' understand why do we have int now.
Code: Select all
short a = 1;
short b = 2;
short c = (short)a + (short)b;
Code: Select all
int c = a + b;
Code: Select all
short c = (short) ( a+b )