Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In C language, int is followed by a number with a decimal, so what is its value?
In C language, int is followed by a number with a decimal, so what is its value?
int(2.5+4.7)=7

In C language, taking int () will force other data types to be converted into int, and the digits after the decimal point will not be rounded directly.

For example:

int b = 10; //Declare the variable as an int type and initialize the assignment.

printf("%f ",b * 5.0); //Print as floating point number, and force 10*5.0 to get 50.000000.

Floating point number a = 2.1314; //Declare the variable as a real number and initialize the assignment.

int c =(int)a; //Declare that the variable C is of int type, and assign the value obtained by forcibly converting A to int type to C, that is, c=2.

Extended data:

Data type keyword:

Short: decorated int, short integer data, decorated int can be omitted. (Introduction to K & ampr Period)

Long: decorated int, long integer data, decorated int can be omitted. (Introduction to K & ampr Period)

Long long: decorated int, which is a long integer data, and can be omitted. (New content of C99 standard)

Signed: modifies integer data and has a signed data type. (C89 standard has been added)

Unsigned: decorated integer data, unsigned data type. (Introduction to K & ampr Period)

Restrict: used to define and constrain pointers and indicate that pointers are the only and initial way to access data objects. (New content of C99 standard)

Baidu encyclopedia -C language