Message365865
Rémi, it is not true that the Decimal module won't lose precision. It will. Decimal is not exact either, it is still a floating point format similar to float.
py> Decimal(1)/3*3
Decimal('0.9999999999999999999999999999')
The two major advantages of Decimal are: it matches the number you type more closely, and you can choose how much precision to use. (At the cost of memory and speed.) But there are also disadvantages: rounding errors with Decimal tend to be larger on average than for binary floats.
If you want exact calculations that will never lose precision, you have to use Fractions, but that is slower and less convenient. |
|
Date |
User |
Action |
Args |
2020-04-06 15:51:16 | steven.daprano | set | recipients:
+ steven.daprano, eric.smith, remi.lapeyre, ahmad dana |
2020-04-06 15:51:16 | steven.daprano | set | messageid: <1586188276.87.0.357381176875.issue40206@roundup.psfhosted.org> |
2020-04-06 15:51:16 | steven.daprano | link | issue40206 messages |
2020-04-06 15:51:16 | steven.daprano | create | |
|