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
| Name | Type | Description |
|---|---|---|
| value | Decimal | The decimal number to be converted into an integer representation. |
| exponent | int | The power of ten by which to multiply the value before conversion, defining the precision of the resulting integer. |
Returns
| Type | Description |
|---|---|
int | The integer representation of the decimal value after scaling by the specified exponent. |