ExNumerlo

ExNumerlo is an Elixir library for rendering and parsing integers using various Unicode numeral systems. It supports over 50 different scripts, including modern positional systems, historical additive and hybrid systems, and specialized mathematical representations.

Features

Add ex_numerlo to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_numerlo, "~> 0.1.0"}
  ]
end

Usage

The sole public interface is ExNumerlo.convert/2, which handles encoding, decoding, and cross-system conversion.

Encoding Integers

To encode an integer (or a list of integers) into a specific numeral system:

ExNumerlo.convert(123, to: :devanagari)
# {:ok, "१२३"}

ExNumerlo.convert(2026, to: :roman)
# {:ok, "MMXXVI"}

ExNumerlo.convert([1, 2, 3], to: :roman)
# {:ok, ["I", "II", "III"]}

Decoding Strings

To decode an encoded string back to an integer, use the to: :integer option. You can specify the source system or let it be auto-detected:

# Explicit source
ExNumerlo.convert("१२३", from: :devanagari, to: :integer)
# {:ok, 123}

# Auto-detection
ExNumerlo.convert("MMXXVI", to: :integer)
# {:ok, 2026}

Separator Support

Positional systems support custom separators for grouping:

ExNumerlo.convert(1234567, to: :arabic, separator: ",")
# {:ok, "1,234,567"}

ExNumerlo.convert("1.234.567", from: :arabic, to: :integer, separator: ".")
# {:ok, 1234567}

Supported Systems

The following systems are currently supported:

LLM Agent Instructions

Usage rules for LLM agents are provided in usage-rules.md for integration with the usage_rules tool.