四舍五入

来源:互联网 发布:国家燃烧知乎 编辑:程序博客网 时间:2024/04/18 14:32
%.nf,其中n是字面常量,功能是输到小数点后面的第n位,第n + 1位“四舍五入”。下面是在VC++ 6.0环境下的测试结果。/*0.2345620.2350.23460.23456Press any key to continue*/#include <stdio.h>int main() { float f = 0.2345623f; printf("%f\n",f); printf("%.3f\n",f); printf("%.4f\n",f); printf("%.5f\n",f); return 0;}
0 0