The regular output of double type is "%lf", but by default, double type outputs 6 digits after the decimal point. We usually need to reduce its length after the decimal point. You can use the form "%m.nlf", where m and n are both positive integers.
The operating environment of this tutorial: Windows 7 system, C 17 version, Dell G3 computer.
The double (double-precision floating point) type is one of the basic types of the C language. It occupies 8 bytes and can be expressed up to 1.7*10^308. Under normal circumstances, it can meet the needs of the program.
The regular output of double is %lf (note that the float type output is %f) For example: define double a = 1.0; use printf("%lf",a);
but the double type By default, the output is 6 digits after the decimal point, and we usually want to reduce its length after the decimal point. You can use the form "%m.nlf", where m and n are both positive integers. m means that the output floating-point data occupies m bits. If the actual length is not equal to m, it will be output according to the actual length. n means the number of decimal points in the output. Therefore, m can actually be ignored, just replace it with 0 or leave it alone!
For example, the above output is: 1.000000 (by default)
If the output format is changed to "%0.0lf" or "%4.0lf", the output will be 1 (m! = actual length )
By the way, the C language does not support the long long int type in VC, but it is supported under Linux. long long int also occupies 8 bytes
Recommended tutorial: "C#"
The above is the detailed content of What is the double output format?. For more information, please follow other related articles on the PHP Chinese website!