回复 第7楼 的 warrenzhang:
换过一组数据就出错了
> 0.3-0.4+0.4
[1] 0.3
> options(digits=20)
> 0.3-0.4+0.4
[1] 0.2999999999999999889
> a=mpfr(c('.3','.4','.3'),200)
> a[1]-a[2]+a[3]
1 'mpfr' number of precision 200 bits
[1] 0.20000000000000000000000000000000000000000000000000000000000019
> a=mpfr(c('.3','.4','.3'),100)
> a[1]-a[2]+a[3]
1 'mpfr' number of precision 100 bits
[1] 0.20000000000000000000000000000024
如果能保证计算结果永远为0.3?