Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Part II — Decimal

Overview (Decimal)

Decimal is an arbitrary-precision decimal type — the Mojo-native equivalent of Python’s decimal.Decimal. It can represent numbers with unlimited digits and decimal places, making it suitable for financial modeling, scientific computing, and applications where floating-point errors are unacceptable.

PropertyValue
NameDecimal
AliasesBigDecimal, BDec
Internal baseBase-10^18 (each word stores ≤ 18 digits)
Default precision28 significant digits
Python equivalentdecimal.Decimal

Decimal, BigDecimal, and BDec are all the same type. We recommend Decimal for consistency with Python’s decimal.Decimal.