DeltaCalc.Decimal (DeltaCalc v0.3.0)

Copy Markdown View Source

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

FunctionArityDescriptionParam Kinds
cast!1Cast an exact input to Decimal, raising on invalid input.value: value
cast1Cast 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

cast_error()

@type cast_error() :: :invalid_decimal

The reason returned when a value is not an exact Decimal input.

input()

@type input() :: Decimal.t() | integer() | String.t()

An exact value accepted by DeltaCalc's calculation boundaries.

Functions

cast(value)

@spec cast(term()) :: {:ok, Decimal.t()} | {:error, cast_error()}

Cast an exact input to Decimal or return a tagged error.

cast!(value)

@spec cast!(term()) :: Decimal.t()

Cast an exact input to Decimal or raise ArgumentError.