On this page
decimal.DecimalTuple
Prev: decimal.DecimalException | Up: decimal | Next: decimal.DivisionByZero
Rel: decimal.Clamped, decimal.Context, decimal.ConversionSyntax, decimal.Decimal
Ref: docs.python.org โ decimal.DecimalTuple
Tags: #public #python3 #stdlib #decimal
Import
import decimal
from decimal import DecimalTuple
Signature & Overview
decimal.DecimalTuple(sign, digits, exponent)
DecimalTuple(sign, digits, exponent)
Methods & Attributes
DecimalTuple.count(self, value, /)โ Return number of occurrences of value.DecimalTuple.index(self, value, start=0, stop=9223372036854775807, /)โ Return first index of value.
Usage
from decimal import Decimal, DecimalTuple
t = Decimal("-12.34").as_tuple()
assert isinstance(t, DecimalTuple) and t == DecimalTuple(sign=1, digits=(1, 2, 3, 4), exponent=-2)
Gotchas
sign=0is positive,sign=1is negative: Can be passed back intoDecimal(t)to reconstruct the exact value.
REPL Inspect
from decimal import DecimalTuple
help(DecimalTuple)
Linked from
Related notes
- tuts/python3/stdlib_module/decimal/DecimalException Linked here; links to this page; shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/DivisionByZero 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/DivisionImpossible shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/DivisionUndefined shared tags: #decimal, #stdlib
- tuts/python3/stdlib_module/decimal/FloatOperation shared tags: #decimal, #stdlib