Skip to main content

Convert numbers across numeral systems — Roman, Chinese, Greek, Egyptian, Arabic-Indic and more.

Project description

numly

A Python library to convert numbers across the world's numeral systems.

PyPI version Python versions License Downloads


What is numly?

numly lets you convert any number between 6 different numeral systems with a single function call.

import numly

numly.convert(42, "decimal", "roman")       # → 'XLII'
numly.convert("XLII", "roman", "chinese")   # → '四十二'
numly.convert("四十二", "chinese", "greek") # → 'ΜΒʹ'
numly.to_all(42)                            # → all systems at once

Supported Numeral Systems

System Example Range
decimal 42 0 – unlimited
roman XLII 1 – 3,999
arabic_indic ٤٢ 0 – unlimited
chinese 四十二 0 – 99,999,999
greek ΜΒʹ 1 – 9,999
egyptian 𓎆𓎆𓎆𓎆𓏺𓏺 1 – 9,999,999

Note: Systems with a range limit will return None in to_all() if the number is out of range.


Installation

pip install numly

Requires Python 3.8 or higher.


Quick Start

import numly

# Convert from decimal to any system
numly.to_roman(2024)              # → 'MMXXIV'
numly.to_chinese(42)              # → '四十二'
numly.to_arabic_indic(2024)       # → '٢٠٢٤'
numly.to_greek(999)               # → 'ϠϘΘʹ'
numly.to_egyptian(1234)           # → '𓆼𓍢𓍢𓎆𓎆𓎆𓏺𓏺𓏺𓏺'

# Convert back to decimal
numly.from_roman('MMXXIV')        # → 2024
numly.from_chinese('四十二')      # → 42
numly.from_arabic_indic('٢٠٢٤')  # → 2024
numly.from_greek('ΜΒʹ')          # → 42
numly.from_egyptian('𓎆𓎆𓏺𓏺')   # → 22

Universal Converter

convert(value, from_system, to_system)

Convert between any two systems directly — no need to go through decimal.

from numly import convert

# decimal → others
convert(42, "decimal", "roman")           # → 'XLII'
convert(42, "decimal", "chinese")         # → '四十二'
convert(42, "decimal", "greek")           # → 'ΜΒʹ'
convert(42, "decimal", "egyptian")        # → '𓎆𓎆𓎆𓎆𓏺𓏺'
convert(42, "decimal", "arabic_indic")    # → '٤٢'

# cross-system (no decimal step needed)
convert("MMXXIV",  "roman",        "chinese")       # → '二千零二十四'
convert("四十二",  "chinese",      "greek")          # → 'ΜΒʹ'
convert("ΜΒʹ",    "greek",         "roman")          # → 'XLII'
convert("٤٢",     "arabic_indic",  "egyptian")       # → '𓎆𓎆𓎆𓎆𓏺𓏺'
convert("𓎆𓎆𓏺𓏺", "egyptian",     "arabic_indic")   # → '٢٢'

# convert to decimal
convert("XLII", "roman", "decimal")       # → 42

to_all(value, from_system="decimal")

Convert a number to all systems at once.

from numly import to_all

to_all(42)
# {
#   'decimal':      42,
#   'roman':        'XLII',
#   'arabic_indic': '٤٢',
#   'chinese':      '四十二',
#   'greek':        'ΜΒʹ',
#   'egyptian':     '𓎆𓎆𓎆𓎆𓏺𓏺'
# }

# from a non-decimal source
to_all("XLII", from_system="roman")

Validation

Each system has an is_valid_* function:

numly.is_valid_roman("XIV")          # → True
numly.is_valid_roman("ABC")          # → False

numly.is_valid_chinese("四十二")     # → True
numly.is_valid_greek("ΜΒʹ")          # → True
numly.is_valid_egyptian("𓎆𓎆𓏺𓏺")  # → True
numly.is_valid_arabic_indic("٤٢")   # → True

Egyptian Symbol Breakdown

from numly import symbol_breakdown

symbol_breakdown(1234)
# {'𓆼': 1, '𓍢': 2, '𓎆': 3, '𓏺': 4}
# meaning: 1 lotus (1000) + 2 rope coils (100) + 3 heel bones (10) + 4 tallies (1)

List All Systems

from numly import supported_systems

supported_systems()
# ['arabic_indic', 'chinese', 'decimal', 'egyptian', 'greek', 'roman']

Error Handling

numly raises clear errors for invalid input:

numly.to_roman(5000)
# ValueError: Roman numerals support 1–3999, got 5000

numly.to_roman("hello")
# TypeError: Expected int, got 'str'

numly.from_roman("XYZ")
# ValueError: Invalid Roman numeral character: 'Y'

What's Not Supported (Yet)

These are planned for future versions:

  • 🔜 Number → English words (42"forty-two")
  • 🔜 Binary / Octal / Hex conversion
  • 🔜 Locale-aware formatting (1,000.00 vs 1.000,00)
  • 🔜 Negative numbers in supported systems
  • 🔜 Babylonian and Mayan numerals
  • 🔜 Numbers beyond 9,999,999 for Egyptian

Full API Reference

Function Input Output
to_roman(n) int str
from_roman(s) str int
is_valid_roman(s) str bool
to_arabic_indic(n) int str
from_arabic_indic(s) str int
is_valid_arabic_indic(s) str bool
to_chinese(n) int str
from_chinese(s) str int
is_valid_chinese(s) str bool
to_greek(n) int str
from_greek(s) str int
is_valid_greek(s) str bool
to_egyptian(n) int str
from_egyptian(s) str int
is_valid_egyptian(s) str bool
symbol_breakdown(n) int dict
convert(value, from, to) any str / int
to_all(value, from) any dict
supported_systems() list

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

git clone https://github.com/TheMadrasTechie/numly.git
cd numly
pip install -e .

License

MIT License © 2026 TheMadrasTechie

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numly-0.2.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numly-0.2.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file numly-0.2.1.tar.gz.

File metadata

  • Download URL: numly-0.2.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for numly-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2e5e31eb4ebd82aa76418b7d180fd4ead991bceabb4359cdd822006c7a003f64
MD5 70bfc8c72d8c14ed372e9faf3a9015d8
BLAKE2b-256 7229036b75b76612113ccba29b2e1cf291d7e9ff722aad181add0d7e0aca71c9

See more details on using hashes here.

File details

Details for the file numly-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: numly-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for numly-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61a231f4136c9840542f2d70c6f767a3a039b6c74a9155c09fffdd10410d60b2
MD5 fe78bfcbe0e94b76a393332f66e51407
BLAKE2b-256 8fc296fca659802f5f860715a312cd96e687517226d104fb266d48da122b73e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page