擅长:python、mysql、java
<p>这是从十进制模块源代码中引用的,该代码解释得很好,如果输入是float,则模块内部调用class方法十进制浮点数()“:</p>
<blockquote>
<p>Note that Decimal.from_float(0.1) is not the same as Decimal('0.1').
Since 0.1 is not exactly representable in binary floating point, the
value is stored as the nearest representable value which is
0x1.999999999999ap-4. The exact equivalent of the value in decimal
is 0.1000000000000000055511151231257827021181583404541015625.</p>
</blockquote>