# `DeltaCalc.Decimal`
[🔗](https://github.com/ZenHive/delta_calc/blob/v0.3.0/lib/delta_calc/decimal.ex#L1)

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` |

# `cast_error`

```elixir
@type cast_error() :: :invalid_decimal
```

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

# `input`

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

An exact value accepted by DeltaCalc's calculation boundaries.

# `cast`

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

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

# `cast!`

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

Cast an exact input to Decimal or raise `ArgumentError`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
