Automatic Typecasting

The conversions that make sense are:

Explicit Typecasting

If you have 2 datatypes. c and i, an explicit typecast of c = i will:

  • Make the right operand the same type as the left operand
  • For high low(consult C Binary Operator Typecasting), excess high-order bits are discarded.
  • For low high, the value of the lower remains unchanged.
int i;
char c;
i = c; // lower char -> higher int
c = i; // higher int -> lower char

Coerced Typecasting

(type-name) expression example is: (double) n

Custom Typecasts