读书人

浮点数格式化输出怎么消零

发布时间: 2012-03-04 11:13:33 作者: rapoo

浮点数格式化输出如何消零?
浮点数格式化输出如何消零?
如 3.12000,输出为3.12
3.1000,输出为3.1
3.0000,输出为3

[解决办法]

C/C++ code
#include <iostream>#include <stdio.h>int _tmain(int argc, _TCHAR* argv[]){    std::cout << 3.12000 << std::endl;    printf( "%g\n", 3.1200 );    return 0;} 

读书人网 >C++

热点推荐