Skip to main content

decimal_as_int

Converts a decimal value to an integer representation by scaling it based on a specified precision.

def decimal_as_int(
value: Decimal,
exponent: int
) - > int

Converts a Decimal value to an integer by multiplying it by a specified power of ten. This is typically used to convert currency or precise decimal values into their smallest unit representation (like cents) for integer-based storage or arithmetic.

Parameters

NameTypeDescription
valueDecimalThe decimal number to be converted into an integer representation.
exponentintThe power of ten by which to multiply the value before conversion, defining the precision of the resulting integer.

Returns

TypeDescription
intThe integer representation of the decimal value after scaling by the specified exponent.