printf和长双 [英] printf and long double

查看:121
本文介绍了printf和长双的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

code:

#include <stdio.h>

int main(void)
{
    float aboat = 32000.0;
    double abet = 5.32e-5;
    long double dip = 5.32e-5;

    printf("%f can be written %e\n", aboat, aboat);
    printf("%f can be written %e\n", abet, abet);
    printf("%lf can be written %le\n", dip, dip);

    return 0;
}

输出:

32000.000000 can be written 3.200000e+004
0.000053 can be written 5.320000e-005
-1950228512509697500000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000.000000
can be written 2.725000e+002
Press [Enter] to close the terminal ...

我使用Windows上的Netbeans最新的gcc。为什么长双不起作用?是的printf说明符错误(%LF)?

Hi, I am using latest gcc with Netbeans on Windows. Why long double doesn't work? Are printf specifiers wrong (%lf)?

推荐答案

除了修改错误,GCC的哪个端口到Windows? MinGW的使用Microsoft C函数库和我似乎记得,这个库中有80bits不支持长双(Microsoft C编译器使用64位长一倍,因各种原因)。

In addition to the wrong modifier, which port of gcc to Windows? mingw uses the Microsoft C library and I seem to remember that that this library has no support for 80bits long double (microsoft C compiler use 64 bits long double for various reasons).

这篇关于printf和长双的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆