Shows the precision of float and double , precision: Refers to the precise degree of the numeric value, floating-point type can represent a large range of values, but only a few are accurate, you can pass the small
The number of digits to be taken, float The number of decimal parts can have up to 7 is a valid number, but it is absolutely guaranteed to be 6 bit, Double The number of small parts is divided into - a valid number, but absolutely guaranteed.
is a the bit
#include <stdio.h>
int main ()
{
Double x=3.0123456789111118;
printf ("%f\n", X);
return 0;
}
The default %f only outputs six digits after the decimal point, to specify how many bits to output need to use the following format
printf ("%.16f\n", X);
#include <stdio.h>
int main ()
{
Double x=3.0123456789111118;
printf ("%a\n", X);
return 0;
}
%A Converts the value of x to a hexadecimal floating-point number,%e is exponential,and%f is in decimal form, and the compiler defaults to seeing the floating-point numbers as Double type
#include <stdio.h>
int main ()
{
Char ch;
ch=97;
printf ("ch:%c\n", ch);
return 0;
}
Char CH, the system allocates a byte space for the variable and places a label ch on that memory space , and%c represents the character type
#include <stdio.h>
int main ()
{
Char ch;
Ch= ' a ';
printf ("ch:%c\n", ch);
printf ("ch:%d\n", (int) ch);
return 0;
}
printf ("ch:%d\n", (int) ch); the role of the output variable CH corresponding to the ASSIIC code value, (int) in the () is a forced type conversion operator, and an int in() represents the type to convert to
A character variable can only hold one character, "' contains a character," "contains a string of characters, so the above ch=' a '; cannot be written ch="a";
#include <stdio.h>
int main ()
{
int i;
for (i=32;i<127;i++)
{
printf ("%c\n", (char) i);
}
return 0;
}
The above program is to output the characters corresponding to the 32~126 ASCII code in turn
#include <stdio.h>
int main ()
{
Char ch1=0;
Char ch2= ' 0 ';
printf ("%d\n%d\n", (int) ch1, (int) CH2);
return 0;
}
Run the above program can get the number 0 corresponding to the ASIIC code of 0, and the character 0 corresponds to the ASIIC Code is
#include <stdio.h>
int main ()
{
float f=3.1415f;
int a=f;
printf ("%d\n", a);
printf ("%f\n", f);
return 0;
}
int a=f; will be F Copy, assign the copied value to the value of the a , so F the value of itself does not change, the format character %f Default Output 6 decimal Places
Signed or unsigned char and short in an expression are automatically converted to int, as illustrated below:
#include <stdio.h>
int main ()
{
Char c1=12,c2=108;
printf ("%d\n", C1+C2);
return 0;
}
and c2 int c1 and c2
when passed as a parameter to the function Char and the Short type will be promoted to int type, float the type will be promoted to Double type, for example:
#include <stdio.h>
int main ()
{
Char ch= ' a ';
printf ("Ch saved ASCII code value:%d\n", ch);
return 0;
}
Ch is automatically converted to int type, so no casting is necessary
The fourth day of C language learning 2