由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - RH3/RH4上cout默认格式问题
相关主题
a C++ interview question..........reverse words, not the Microsoft one!!!
C++ formatted output questionabout new operator
问个指针array 的简单问题关于C++中一个Class的大小 (转载)
[合集] 一个依赖于平台的memory问题C++里面
A try-catch problem in C++两个继承问题
a simple question for C++ class为什么我看不懂下面的code,是不是水平还不够?
which func will be called?C++ 弱问一个
请问一个exception题目C++疑问
相关话题的讨论汇总
话题: std话题: rh3话题: rh4话题: 1e话题: include
进入Programming版参与讨论
1 (共1页)
g*********s
发帖数: 1782
1
#include
#include
#include
#include
int main(){
float f = 0.0001;
printf("f = %f\n", f);
printf("f = %g\n", f);
printf("f = %e\n", f);
std::cout <<"f = "< std::cout.setf(std::ios_base::fmtflags(0), std::ios_base::floatfield);
std::cout <<"f = "< }
RH3:
f = 0.000100
f = 1e-04
f = 1.000000e-04
f = 1e-04
f = 1e-04
RH4:
f = 0.000100
f = 0.0001
f = 1.000000e-04
f = 0.0001
f = 0.0001
有啥办法统一格式么?机器是RH3/RH4都有。改程序也
g*********s
发帖数: 1782
2
For float f2 = 0.0002, there's no such difference b/w RH3 and RH4. Both
output 0.0002.
So it seems 1e-04 is a bug in RH3.

【在 g*********s 的大作中提到】
: #include
: #include
: #include
: #include
: int main(){
: float f = 0.0001;
: printf("f = %f\n", f);
: printf("f = %g\n", f);
: printf("f = %e\n", f);
: std::cout <<"f = "<
1 (共1页)
进入Programming版参与讨论
相关主题
C++疑问A try-catch problem in C++
c++ 是否也有class method??a simple question for C++ class
two c++ interview questions! (转载)which func will be called?
请教一个作用域的问题请问一个exception题目
a C++ interview question..........reverse words, not the Microsoft one!!!
C++ formatted output questionabout new operator
问个指针array 的简单问题关于C++中一个Class的大小 (转载)
[合集] 一个依赖于平台的memory问题C++里面
相关话题的讨论汇总
话题: std话题: rh3话题: rh4话题: 1e话题: include