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 = "<
|
|