all Python 3Exceptionsexception
decimal.Rounded
module exceptions
A decimal result was rounded (even if no precision was lost).
Syntax
raise decimal.Rounded
Treat this as a signal rather than an error: its trap is off by default, and you detect it by reading getcontext().flags[decimal.Rounded] — the flag is sticky and stays set until you call clear_flags. Do not confuse it with Inexact: Rounded fires whenever digits are discarded at all, even discarded zeros that leave the value unchanged, while Inexact fires only when something non-zero was actually lost.
Examples
import decimal
try:
raise decimal.Rounded
except decimal.Rounded as e:
print(type(e).__name__) # → Rounded
See also
Open in the full glossarydocs.python.orgReport an inaccuracy