# `Unicode.NumericType`
[🔗](https://github.com/elixir-unicode/unicode/blob/v2.2.0/lib/unicode/property/numeric_type.ex#L1)

Functions to introspect the Unicode `Numeric_Type` property for binaries (Strings) and codepoints.

The `Numeric_Type` property classifies how a codepoint represents a number. The values are `:decimal`, `:digit` and `:numeric`; codepoints that are not numeric have the value `:none`.

The primary API is `numeric_type/1` which returns the numeric type of a codepoint, or the list of numeric types of a string. See `Unicode.NumericValue` for the associated numeric values.

# `aliases`

Returns a map of aliases for Unicode numeric types.

### Returns

* A map where the alias string is the key and the numeric type is the value.

### Examples

    iex> Unicode.NumericType.aliases() |> Map.get("de")
    :decimal

# `count`

Returns the count of the codepoints with a given numeric type.

Aliases are resolved by this function.

### Arguments

* `numeric_type` is any numeric type name or alias, as an atom or string.

### Returns

* A non-negative integer count of the codepoints with the numeric type.

* `:error` if the numeric type is not known.

### Examples

    iex> Unicode.NumericType.count(:decimal)
    770

# `fetch`

Returns the Unicode codepoint ranges for a given numeric type.

Aliases are resolved by this function.

### Arguments

* `numeric_type` is any numeric type name or alias, as an atom or string.

### Returns

* `{:ok, range_list}` where `range_list` is a list of codepoint ranges as 2-tuples.

* `:error` if the numeric type is not known.

### Examples

    iex> Unicode.NumericType.fetch(:decimal) |> elem(0)
    :ok

    iex> Unicode.NumericType.fetch(:invalid)
    :error

# `get`

Returns the Unicode codepoint ranges for a given numeric type.

Aliases are resolved by this function.

### Arguments

* `numeric_type` is any numeric type name or alias, as an atom or string.

### Returns

* A list of codepoint ranges as 2-tuples.

* `nil` if the numeric type is not known.

### Examples

    iex> Unicode.NumericType.get(:invalid)
    nil

# `known_numeric_types`

Returns a list of known Unicode numeric type names.

### Returns

* A list of atom numeric type names.

### Examples

    iex> :decimal in Unicode.NumericType.known_numeric_types()
    true

# `numeric_type`

Returns the numeric type of the given binary or codepoint.

### Arguments

* `string_or_codepoint` is either a binary (String) or a codepoint in the range `0..0x10FFFF`.

### Returns

* For a codepoint, a single numeric type atom is returned. Non-numeric codepoints return `:none`.

* For a binary, a list of the distinct numeric types of the codepoints in the binary is returned.

### Examples

    iex> Unicode.NumericType.numeric_type(?1)
    :decimal

    iex> Unicode.NumericType.numeric_type(?A)
    :none

    iex> Unicode.NumericType.numeric_type(?½)
    :numeric

# `numeric_types`

Returns the map of Unicode numeric types.

### Returns

* A map where the numeric type is the key and a list of codepoint ranges as 2-tuples is the value.

### Examples

    iex> Unicode.NumericType.numeric_types() |> Map.keys() |> Enum.sort()
    [:decimal, :digit, :none, :numeric]

---

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