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.
", f);
        printf("float: %e.

", f);

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

", d);

        printf("long double: %Lf.
", ld);
        printf("long double: %lf.
", ld);
        printf("long double: %le.
", 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.
原文地址:https://www.cnblogs.com/liujiaxin2018/p/15063696.html