dango_decimal
Return the canonical fixed-decimal string form of x. Raises if precision is lost.
Signature
def dango_decimal(
x: float | int | str | Decimal,
max_places: int = 6,
) -> strExample
from decimal import Decimal
from dango.utils.types import dango_decimal
dango_decimal(1.5) # "1.500000"
dango_decimal("1.5") # "1.500000"
dango_decimal(Decimal("1.5")) # "1.500000"
dango_decimal(1500) # "1500.000000"Parameters
x — float | int | str | Decimal. The value to canonicalise. bool and NaN/Inf are rejected.
max_places — int, optional. Maximum allowed fractional digits. Values requiring more precision raise ValueError. Default: 6 (matches the Dango wire convention for UsdValue / UsdPrice / Dimensionless / Quantity).
Returns
str — a fixed-point decimal string with exactly max_places fractional digits.
Notes
- Used by every method that constructs a
UsdValue/UsdPrice/Dimensionless/Quantityfield on the wire. - For
Uint128/Uint64(order ids, share counts, base-unit amounts), stringify withstr(int_value)— not this helper.
See also
- Concepts: Encoding & Types — wire-format conventions