荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: Version (西风。。), 信区: Program
标 题: Re: 请问一下C++设置浮点精度问题
发信站: 荔园晨风BBS站 (Sun Jun 29 09:26:55 2003), 站内信件
MSDN:
precision:
Return Value
The first overloaded precision function sets the stream's internal
floating-point precision variable to np and returns the previous value.
The default precision is six digits. If the display format is
~~~~~~~~~~~~~~~~~~~~~~~~~~
scientific or fixed, the precision indicates the number of digits
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
after the decimal point. If the format is automatic (neither floating
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
point nor fixed), the precision indicates the total number of
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
significant digits.
(有效数字)~~~~~~~~
The second function returns the stream's current precision value.
【 在 Kenniel (是时候静下来看看书了) 的大作中提到: 】
: 不知道是不是因为vc版本不一样所以会出现
: 这个问题
: #include <iostream.h>
: #include <iomanip.h>
: #include <math.h>
: void main()
: {
: double root = sqrt( 2.0 );
: for( int place = 0 ; place <= 9 ; place++ )
: {
: cout.precision( place );
: cout<<root<<endl;
: }
: }
: 运行发现精度和书上讲的不一样!讨论讨论呵呵!
--
*
* *
* *
no more to say
★ just wish you ★
good luck
※ 修改:·Version 於 Jun 29 09:27:08 修改本文·[FROM: 192.168.1.50]
※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.1.50]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店