Skip to content

Commit d3770eb

Browse files
committed
chore: expand decimal precision comment
1 parent e0a1150 commit d3770eb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

crypto/utils/unit_converter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
from decimal import Decimal, getcontext
33
from typing import Union
44

5-
# 78 digits to cover uint256 max value (2^256 - 1)
5+
# Python's Decimal type defaults to 28 digits of precision, which is not enough
6+
# for blockchain math. The largest possible value (uint256) has 78 digits, so we
7+
# increase the precision to 78 to avoid rounding errors when working with big numbers.
68
getcontext().prec = 78
79

810
class UnitConverter:

0 commit comments

Comments
 (0)