Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The difference between double and int in C language, and the difference between %d and% f.
The difference between double and int in C language, and the difference between %d and% f.
Int: Integer, that is, an integer variable in our usual sense, such as 1, 2, 3, 4, 5, etc.

Double: a double-precision real number, that is, a decimal in our usual sense, such as 1.25, 1.37, 5.0, etc.

%d: This is the format used by scanf to enter integers in C language. The format of the input integer is scanf ("%d ",&; Answer.

%f: This is the format used by scanf to input decimals in C language, and the format of input integers is scanf ("%lf ",&; Answer.

In your formula C=(F-32)*5/9, the calculation result should be double precision, and you can't use int to define variables. If the assignment is forced, the data will be lost: the decimal part will be lost, and only the integer part will be kept.

Extended data

Double is a data type used by computers. It uses 64 bits (8 bytes) to store a floating-point number. It can represent decimal 15 or 16 significant digits, and the absolute value range of digits can be about: 2.23x 10-308? ~1.79x10308.ieee754 customized the standard for it.

In C/C++ programming language, int stands for integer variable, which is a data type and is used to define integer variable. It has different sizes in different compilation environments and different compilation and running environments. In the 32/64-bit system, there are 32 bits, ranging from-2147483648 ~+2147483647, which is expressed as 0~4294967295 under unsigned conditions.

reference data

Baidu Encyclopedia _ Double Precision Floating Point Number

Baidu encyclopedia _int function