printf 和 long double [英] printf and long double

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

问题描述

我在 Windows 上使用带有 Netbeans 的最新 gcc.为什么 long double 不起作用?printf 说明符 %lf 错了吗?

I am using the latest gcc with Netbeans on Windows. Why doesn't long double work? Is the printf specifier %lf wrong?

代码:

#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
", aboat, aboat);
    printf("%f can be written %e
", abet, abet);
    printf("%lf can be written %le
", 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 ...

推荐答案

除了修改器错误外,gcc 有哪些端口到windows?mingw 使用的是微软 C 库,我好像记得这个库不支持 80bits long double(微软 C 编译器因为各种原因使用 64 位 long double).

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

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

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