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.
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
Noneinto_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.00vs1.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numly-0.2.0.tar.gz.
File metadata
- Download URL: numly-0.2.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f30c8e2025a7de47008b206c907ba156b543ed31c48a23957c06e20e0a1b00d3
|
|
| MD5 |
8e204368c21406460fc8660646e30ef5
|
|
| BLAKE2b-256 |
15c6c99bf6fb1dc3a3ea1cb83779b30827a04a29d7f14200c01d006b84058937
|
File details
Details for the file numly-0.2.0-py3-none-any.whl.
File metadata
- Download URL: numly-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fa45973c9c7aea79ec8c1bc5bb326fb9d0e1a1d79fc1cc662be514098df9e23
|
|
| MD5 |
ba348ffef006eac1385a3d15018f595e
|
|
| BLAKE2b-256 |
3fd255b6a51927c38687c45fce2a6f97c48c84568a4ee284e4870feef1326280
|