On this page
decimal.Rounded
Prev: decimal.Overflow | Up: decimal | Next: decimal.setcontext
Rel: decimal.Clamped, decimal.Context, decimal.ConversionSyntax, decimal.Decimal
Ref: docs.python.org โ decimal.Rounded
Tags: #public #python3 #stdlib #decimal
Import
import decimal
from decimal import Rounded
Signature & Overview
decimal.Rounded(...)
decimal.Rounded class.
Methods & Attributes
Rounded.add_note(self, note, /)โ Add a note to the exceptionRounded.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
from decimal import Decimal, Rounded, localcontext
with localcontext() as ctx:
ctx.prec = 3
_ = Decimal("1") / Decimal("3")
assert ctx.flags[Rounded] is True
Gotchas
- Untrapped flag by default: Check
ctx.flags[Rounded]to see whether any operation in the block lost digits.
REPL Inspect
from decimal import Rounded
help(Rounded)
Linked from
Related notes
- tuts/python3/stdlib_module/decimal/Overflow Linked here; links to this page; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/setcontext Linked here; links to this page; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/Clamped Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/Context Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/ConversionSyntax Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/Decimal Linked here; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/decimal/DecimalException shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/DecimalTuple shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/DivisionByZero shared tags: #decimal, #stdlib