short a, b, c; c = (a + b) / 2; c = a / 2 + b / 2; c = ((int)a + b) / 2;
a + b > 32767
(Ierakstīt jaunu komentāru)
-9- Many binary operators that expect operands of arithmetic or enumeration type cause conversions and yield result types in a similar way. The purpose is to yield a common type, which is also the type of the result. This pattern is called the usual arithmetic conversions, which are defined as follows: [..]* otherwise, the integral promotions (conv.prom) shall be performed on both operands.*
-1- An rvalue of type char, signed char, unsigned char, short int, or unsigned short int can be converted to an rvalue of type int [..]
(Atbildēt uz šo) (Diskusija)
(Atbildēt uz šo) (Iepriekšējais)