如何确定双精度的最大精度

如何确定双精度的最大精度

本文介绍了如何确定双精度的最大精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定双精度的最大精度。在此链接中接受的答案的评论中 @PeterLawrey在15中表示最大精度。

I am trying to determine what the maximum precision for a double is. In the comments for the accepted answer in this link Retain precision with double in Java @PeterLawrey states max precision in 15.

您如何确定?

推荐答案

这其实不是他所说的。他所说的是:

That's actually not what he stated at all. What he stated was:

他错了。它们具有15位十进制数字的精确度。

and he is wrong. They have 15 decimal digits of accuracy.

任何数字中的小数位数由其日志提供给基数10. 15是log 10的底值(2 -1),其中53是尾数(包括隐含位)的位数,如Javadoc和IEEE中所述754和2 -1是最大可能的尾数值。实际值为15.954589770191003298111788092734到Windows计算器的限制。

The number of decimal digits in any number is given by its log to the base 10. 15 is the floor value of log(2-1), where 53 is the number of bits of mantissa (including the implied bit), as described in the Javadoc and IEEE 754, and 2-1 is therefore the maximum possible mantissa value. The actual value is 15.954589770191003298111788092734 to the limits of the Windows calculator.

将其描述为精确度的小数位是错误的。如果小数点都在小数点之前, double 具有精度的十进制数字。对于具有小数部分的数字由于十进制和二进制分数的不可比性,可以在十进制表示中获得超过15位的数字。

He is quite wrong to describe it as 'decimal places of accuracy'. A double has 15 decimal digits of accuracy if they are all before the decimal point. For numbers with fractional parts you can get many more than 15 digits in the decimal representation, because of the incommensurability of decimal and binary fractions.

这篇关于如何确定双精度的最大精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 23:59