Usual arithmetic conversions in C : Whats the rationale behind this particular rule

后端 未结 3 410
时光取名叫无心
时光取名叫无心 2021-01-21 17:14

From k&R C

  • First, if either operand is long double, the other is converted to long double.
  • Otherwise, if either o
3条回答
  •  暖寄归人
    2021-01-21 18:15

    Do these conversions happen if a, b and c were short ?

    Yes, integer promotions are done on all small integer types: char, short and C99 bool.

    Strictly speaking, a C program cannot perform any form of arithmetic on anything smaller than an int, unless the compiler optimizes away the integer promotions.

提交回复
热议问题