decimal.Decimal.quantize()
decimal.Decimal.quantize() is a Python method in the Decimal Module category. Rounds a Decimal to the given exponent (for currency formatting). The syntax is Decimal.quantize(exp, rounding=None, context=None). Parameters: exp — exponent Decimal. Returns: Rounded Decimal. A typical example: Decimal("3.14159").quantize(Decimal("0.01")) # Decimal("3.14"). A close sibling is decimal.Decimal(), which creates a Decimal number from a string, integer, or float. Provides exact decimal arithmetic. A close sibling is decimal.getcontext(), which returns the current thread-local Decimal context (precision, rounding, traps). A close sibling is decimal.localcontext(), which returns a context manager that temporarily changes the decimal precision. More about this category: Decimal fixed-point arithmetic — Decimal, getcontext, quantize. Related Decimal Module entries: decimal.Decimal(), decimal.getcontext(), decimal.localcontext(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try decimal.Decimal.quantize() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.