<p>作为<a href="https://stackoverflow.com/questions/63264446/number-type-with-accuracy-information?noredirect=1#comment111872143_63264446">commented by Eric Postpischil</a>,这是“<a href="https://en.wikipedia.org/wiki/Interval_arithmetic" rel="nofollow noreferrer">interval arithmetic</a>和相关概念”</p>
<p>谷歌搜索<a href="https://www.google.com/search?client=firefox-b-d&q=python+interval+arithmetic" rel="nofollow noreferrer">python interval arithmetic</a>发现<a href="https://pyinterval.readthedocs.io/en/latest/" rel="nofollow noreferrer">PyInterval</a>。让我们试试:</p>
<pre><code>from interval import interval
p = interval[1]
for i in range(10**6):
p *= (2**32 - i) / 2**32
print(p)
</code></pre>
<p>输出(运行<a href="https://repl.it/repls/RedundantFelineAttribute#main.py" rel="nofollow noreferrer">on repl.it</a>):</p>
<pre><code>interval([2.7390147473969355e-51, 2.739014747831127e-51])
</code></pre>
<p>让我们将其与<a href="https://stackoverflow.com/a/63264447/13008439">integer calculation</a>的边界进行比较:</p>
<pre><code>interval upper 2.739014747831127e-51
integer upper 27390147476140722271150280539996691121583143640960
integer lower 27390147476140722271150280539996691121583143636646
interval lower 2.7390147473969355e-51
</code></pre>
<p>因此<code>interval</code>解的精度较低(它是一个较大的区间,只有下界和上界的前十位匹配),但它是正确的(实际值确实在区间内)。从这个意义上说,我想它永远是正确的,尽管我没有研究它是如何工作的</p>