Home>Article>Backend Development> What does double mean in c language
Double in the C language means to define a variable as a double-precision real variable, which means that the value assigned to the variable will be stored in memory in double-precision real format.
double is a keyword in C language, which represents double-precision floating point type.
Occupies 8 bytes (64 bits) of memory space. The numerical value range is 1.7E-308 ~ 1.7E 308. The effective number of fully guaranteed double precision is 15 digits, and 16 digits are only guaranteed for some values.
You can use the formatted input and output statements scanf and printf to perform double type input and output. The formatting character is %lf.
Type conversion in assignment
When the operand types on both sides of the assignment operator are different, type conversion will occur. The conversion rule is: convert the type of the expression on the right side of the assignment operator is the type of the variable on the left. The specific conversion is as follows:
1. Floating point type and integer type
When converting single and double precision) to integer, the decimal part of the floating point number will be discarded and only the integer part will be retained. Assign an integer value to a floating-point variable. The value remains unchanged, but the form is changed to floating-point form, that is, there are several 0s after the decimal point. Note: Type conversion during assignment is actually mandatory.
2. Single and double precision floating point types
Since floating point values in C language are always expressed in double precision, float type data is only extended to double type by adding 0 at the end. The data participates in the operation and then is assigned directly. When double type data is converted to float type, it is realized by truncation, and rounding operation is required before truncation.
3. Char type and int type
When an int type value is assigned to a char type variable, only the lowest 8 bits are retained, and the high bits are discarded.
When a char type value is assigned to an int type variable, some compilers will treat it as a positive number regardless of the value, while other compilers will treat it as a negative number if the char type data value is greater than 127 during conversion. .
For users, if the original char type data has a positive value, it will still be a positive value after conversion; if the original char type value can be positive or negative, the original value will still be maintained after conversion, but the data The internal representation is different.
Recommended tutorial: "c Language Tutorial"
The above is the detailed content of What does double mean in c language. For more information, please follow other related articles on the PHP Chinese website!