ExNumerlo

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

Installation

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

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

Usage

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

Encoding Integers

To encode an integer into a specific numeral system:

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

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

Decoding Strings

To decode an encoded string back to an integer, you can specify the source system or use :auto detection:

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.