c语言中浮点数的声明与输出

c语言中浮点数的声明与输出。

[root@centos79 test]# cat test2.c
#include <stdio.h>

int main(void)
{
        float f = 1000.0;
        double d = 1000.0;
        long double ld = 1000.0;

        printf("float: %f.\n", f);
        printf("float: %e.\n\n", f);

        printf("double: %f.\n", d);
        printf("double: %e.\n\n", d);

        printf("long double: %Lf.\n", ld);
        printf("long double: %lf.\n", ld);
        printf("long double: %le.\n", ld);

        return 0;
}
[root@centos79 test]# gcc test2.c && ./a.out
float: 1000.000000.
float: 1.000000e+03.

double: 1000.000000.
double: 1.000000e+03.

long double: 1000.000000.
long double: 1000.000000.
long double: 1.000000e+03.

 

上一篇:[转]Ubuntu18.04安装uwsgi错误:error: lto-wrapper failed collect2: error: ld returned 1 exit status


下一篇:基于LD3320语音识别模块的智能照明系统