One, coercion type conversion
printf ("3/2+100.5=%f", 3/2+100.5);//100.5 Error expression
printf ("(float) 3/(float) 2 +100.5f=%f \ n", (float) 3/(float) 2 +100.5f); (float) Prefix
Two, automatic type conversion and implicit type conversion
Example 1:
printf ("3/2+100.5=%f \ n", (float) 3/2 +100.5f);
printf ("3/2+100.5=%f \ n", 3/(float) 2 +100.5f);
printf ("3/2+100.5=%f \ n", 3/2.0f +100.5f);
printf ("3/2+100.5=%f \ n", 3.0f/2 +100.5f);
Example 2:
Char v1=2;
Short v2=111111;
float v3=3.45;
Double V4=10.0f/3;
V1=v2;
printf ("V1=%hd,v2=%hd,v3=%f,v4=%f \ n", v1,v2,v3,v4);
Example 3:
int a=3,b=2;
float c=100.5f;
printf ("3/2+100.5=%f \ n", a/b+c);
printf ("3/2+100.5=%f \ n", (float) a/b+c);
printf ("3/2+100.5=%f \ n", A/(float) b+c);
Conversion Order: Automatically translates to high types for calculation when low and high type operations are performed
Char, Short,int,long long,float,double
C language Coercion type conversion