开发者社区> 问答> 正文

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中会变成这样奇怪的数字,应该如何设置或修改?
菜鸟拜谢大神~~~!!!

展开
收起
a123456678 2016-06-06 18:53:55 1679 0
1 条回答
写回答
取消 提交回答
  • 这是Xcode 的debug显示,跟程序的输出没关系,取决于Xcode debug 对于各种类型变量的显示方式

    2019-07-17 19:29:17
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载