# `DecimalEnv`
[🔗](https://github.com/gmtprime/decimal_env/blob/v1.0.1/lib/decimal_env.ex#L1)

This module provides macros to encapsulate `Decimal` operations while using
Elixir arithmetic and comparison operators and functions.

# `context`

```elixir
@type context() :: nil | keyword() | Decimal.Context.t()
```

Context.

# `option`

```elixir
@type option() :: {:as, type_name()} | {:context, context()}
```

Option.

# `options`

```elixir
@type options() :: [option()]
```

Options.

# `output`

```elixir
@type output() :: integer() | float() | binary() | Decimal.t()
```

Output type.

# `type_name`

```elixir
@type type_name() ::
  nil | :decimal | :float | :integer | :string | :scientific | :xsd | :raw
```

Type name.

# `decimal`
*macro* 

```elixir
@spec decimal(options(), Macro.t()) :: Macro.t()
```

Runs a block under the `Decimal` environment. All numeric values will be
converted to `Decimal`.

Options:
  - `:context` - `Decimal.Context` struct. it can also be a `keyword` list.
  - `:as` - In which type we should have the result. The possible values are
    the following:
    + `:decimal` (default)
    + `:float`
    + `:integer`
    + `:string`
    + `:xsd`
    + `:raw`
    + `:scientific`

## Examples

    iex> import DecimalEnv
    iex> decimal do: 42.42
    Decimal.new("42.42")
    iex> decimal do: 84.0 - 21 - "21"
    Decimal.new("42.0")
    iex> decimal as: :scientific do
    ...>   "0.0000000002" + 0.000000004
    ...> end
    "4.2E-9"
    iex> decimal context: [precision: 2, rounding: :ceiling], as: :integer do
    ...>   21.1 + 20
    ...> end
    42

---

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