Xcode编译C语言显示完整浮点数
我用Xcode作为编译器学习C语言,代码如下:
#include <stdio.h>
int main(void)
{
float weight;
float value;
printf("are you worth your weight in rhodium?\n");
printf("let's check it out.\n");
printf("please enter your weight in pounds: ");
scanf("%f", &weight);
value = 770 * weight * 14.5833;
printf("your weight in rhodium is worth $%.2f.\n", value);
printf("you are easily worth that! If rhodium prices drop,\n");
printf("eat more to maintain your value.\n");
return 0;
}
按理说代码应该没有问题,但是我编译后输出结果却是这样:
are you worth your weight in rhodium?
let's check it out.
please enter your weight in pounds: 150
your weight in rhodium is worth $310815099620643345268736.00.
you are easily worth that! If rhodium prices drop,
eat more to maintain your value.
另外,我发现Xcode中有以下内容:
我用其他编译器显示的是正确的结果。请问为什么Xcode中会变成这样奇怪的数字,应该如何设置或修改?
菜鸟拜谢大神~~~!!!
带风扇去上课
10 years, 3 months ago