Re: [cpp] std::cout 为啥和 printf 的结果不一致
Jack
guitar2002star at gmail.com
Thu Nov 1 14:07:10 CST 2007
是不是和你设置了cout的精度有关呢。
在07-11-1,jinq0123 at 163.com <jinq0123 at 163.com> 写道:
>
> 用stlport就输出一致,应该是库的错误。恭喜你找到一个BUG。
>
> Xu Ziding wrote:
> > 代码如下:
> > double d = 123456789e300;
> > std::cout.precision(0);
> > std::cout << std::fixed << d << std::endl;
> > printf("%f\n", d );
> > 我的VC7.1,DEBUG编译输出如下:
> >
> 123456789000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
> >
> 123456789000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
> > RELEASE:
> >
> 123456789000000170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
> >
> 123456789000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
> >
> > 为啥数大了之后,printf和流输出的值还不一样啊?而且debug和release的版本的输出也不一样呢?
> >
> > ZiDing
> >
> > 10.29
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Cpp mailing list
> > Cpp at codingnow.com
> > http://codingnow.com/mailman/listinfo/cpp
> >
>
>
> --
> 金庆
>
> 欢迎访问:金庆的专栏 ( http://blog.csdn.net/jq0123 )
> 欢迎加入:上海程序员 ( http://groups.google.com/group/programmers_sh )
>
>
>
>
> _______________________________________________
> Cpp mailing list
> Cpp at codingnow.com
> http://codingnow.com/mailman/listinfo/cpp
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20071101/f3e7d1f3/attachment.html
More information about the Cpp
mailing list