Header menu

_________________________________________________________________________________

Wednesday, 6 September 2017

Type Conversion in expressions in C

When constants and variable of different types are mixed in an expression, they are converted to the same type . The C compiler will convert all operands to the type of largest operand. This is done on an operation by operation basis following type conversion rules.

1. All chars and short int are converted to int. All floats are converted to doubles.

2. For all operand pairs: if one of the operands is double, the other operand is converted to double. Otherwise, if one of the operands is long, the other operand is converted to long.; if one of the operands is unsigned, the other is converted to unsigned

No comments:

Post a Comment