这个问题在这里已经有了答案:
gcc: printf and long double leads to wrong output. [C - Type conversion messes up]
(5 个回答)
6年前关闭。
当我运行下面的 Ansi C 程序时,会打印出“0.000000”的值。有谁知道为什么值“561.308000”没有被打印出来?我使用的是 Dev-C++ 来运行程序,我使用的编译器是:GCC 的 Mingw 端口(GNU Compiler Collection),版本 MSVCRT 2.95.2-1。
#include <stdio.h>
#include <stdlib.h>
main()
{
long double x = 561.308;
printf("%Lf",x);
}
最佳答案
编译 gcc (GCC) 4.8.1
在使用此命令的 Windows 7 64 位上工作。 (将 -std=c99
添加到让编译器与 C99 一起工作的选项中)gcc -Wall -Wextra -std=c99 test.c -o test.exe
关于c - 安思 C : Long Double Variable Printing Out to a Value of 0. 000000,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32686906/