# `Machete.FloatMatcher`
[🔗](https://github.com/mtrudel/machete/blob/main/lib/machete/matchers/float_matcher.ex#L1)

Defines a matcher that matches float values

# `opts`

```elixir
@type opts() :: [
  positive: boolean(),
  strictly_positive: boolean(),
  negative: boolean(),
  strictly_negative: boolean(),
  nonzero: boolean(),
  min: float(),
  max: float(),
  roughly: float(),
  epsilon: float() | {float(), float()}
]
```

Describes the arguments that can be passed to this matcher

# `t`

```elixir
@opaque t()
```

Describes an instance of this matcher

# `float`

```elixir
@spec float(opts()) :: t()
```

Matches against float values

Takes the following arguments:

* `positive`: When `true`, requires the matched float be positive or zero
* `strictly_positive`: When `true`, requires the matched float be positive and nonzero
* `negative`: When `true`, requires the matched float be negative or zero
* `strictly_negative`: When `true`, requires the matched float be negative and nonzero
* `nonzero`: When `true`, requires the matched float be nonzero
* `min`: Requires the matched float be greater than or equal to the specified value
* `max`: Requires the matched float be less than or equal to the specified value
* `roughly`: Requires the matched float be within `epsilon` of the specified value
* `epsilon`: The bound(s) to use when determining how close the matched integer needs to be to
  `roughly`. Can be specified as a single float that is used for both lower and upper bounds,
  or a tuple consisting of distinct lower and upper bounds. If not specified, and if `roughly`
  is not zero, defaults to 5% of the value

Examples:

    iex> assert 1.0 ~> float()
    true

    iex> assert 1.0 ~> float(positive: true)
    true

    iex> assert 0.0 ~> float(positive: true)
    true

    iex> assert -1.0 ~> float(positive: false)
    true

    iex> refute 0.0 ~> float(positive: false)
    false

    iex> assert 1.0 ~> float(strictly_positive: true)
    true

    iex> refute 0.0 ~> float(strictly_positive: true)
    false

    iex> assert -1.0 ~> float(strictly_positive: false)
    true

    iex> assert 0.0 ~> float(strictly_positive: false)
    true

    iex> assert -1.0 ~> float(negative: true)
    true

    iex> assert 0.0 ~> float(negative: true)
    true

    iex> assert 1.0 ~> float(negative: false)
    true

    iex> refute 0.0 ~> float(negative: false)
    false

    iex> assert -1.0 ~> float(strictly_negative: true)
    true

    iex> refute 0.0 ~> float(strictly_negative: true)
    false

    iex> assert 1.0 ~> float(strictly_negative: false)
    true

    iex> assert 0.0 ~> float(strictly_negative: false)
    true

    iex> assert 1.0 ~> float(nonzero: true)
    true

    iex> assert 0.0 ~> float(nonzero: false)
    true

    iex> assert 2.0 ~> float(min: 2.0)
    true

    iex> assert 2.0 ~> float(max: 2.0)
    true

    iex> assert 95.0 ~> float(roughly: 100.0)
    true

    iex> assert -95.0 ~> float(roughly: -100.0)
    true

    iex> assert 90.0 ~> float(roughly: 100.0, epsilon: 10.0)
    true

    iex> assert -90.0 ~> float(roughly: -100.0, epsilon: 10.0)
    true

    iex> assert 105.0 ~> float(roughly: 100.0, epsilon: {10.0, 5.0})
    true

    iex> assert -110.0 ~> float(roughly: -100.0, epsilon: {10.0, 5.0})
    true

    iex> refute 94.0 ~> float(roughly: 100.0)
    false

    iex> refute 89.0 ~> float(roughly: 100.0, epsilon: 10.0)
    false

    iex> refute 106.0 ~> float(roughly: 100.0, epsilon: {10.0, 5.0})
    false

---

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