Arithmetic type conversion rule for float types and int types.

Q15. Write arithmetic type conversion rule for float types and int types.

Ans. Arithmetic type conversion rule for float types:

If either operand is float, the other operand is converted to float.

Arithmetic type conversion rule for int types:

If an int (in both their signed and unsigned varieties) can represent all the values of the original type, the value is converted to int; otherwise it is converted to unsigned int. this process is called integral promotion.

Then, if either operand is unsigned long, the other is converted to unsigned long.

Otherwise, if one operand is a long int and the other unsigned int, then if a long int can represent all the values of an unsigned int, the unsigned int is converted to long int; otherwise both operands is converted to unsigned long int.

Otherwise, if either operand is long, the other is converted to long.

Otherwise, if either operand is unsigned, the other is converted to unsigned.

Otherwise, both operands are int.

Leave a Reply

Your email address will not be published. Required fields are marked *

503 Views
%d bloggers like this: