浮点数格式化输出如何消零?
浮点数格式化输出如何消零?
如 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;}