Wednesday, January 11, 2012

What happens if we try to assign an integer type value to a float type variable?

C puts a decimal point at the end and converts the method of storage to exponential binary form and store the result in the variable's memory cell. Thus,

p = 6/4;

takes the integer value (6/4, which becomes 1 due to the cutting off of the fractional part), converts this to 1.0 (with a decimal point meaning it is in exponential binary form), and stores this in the memory cell for the variable.

No comments:

Post a Comment