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.

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐