Exact input coercion for DeltaCalc's Decimal calculations.
Accepted inputs are existing Decimal values, integers, and complete decimal
strings. Floats are rejected because they cannot represent arbitrary decimal
values exactly.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
cast! | 1 | Cast an exact input to Decimal, raising on invalid input. | value: value |
cast | 1 | Cast an exact input (Decimal, integer, or complete decimal string) to Decimal. | value: value |
Summary
Types
The reason returned when a value is not an exact Decimal input.
An exact value accepted by DeltaCalc's calculation boundaries.
Functions
Cast an exact input to Decimal or return a tagged error.
Cast an exact input to Decimal or raise ArgumentError.
Types
Functions
@spec cast(term()) :: {:ok, Decimal.t()} | {:error, cast_error()}
Cast an exact input to Decimal or return a tagged error.
Cast an exact input to Decimal or raise ArgumentError.