numly 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
numly-0.2.2/PKG-INFO ADDED
@@ -0,0 +1,418 @@
1
+ Metadata-Version: 2.4
2
+ Name: numly
3
+ Version: 0.2.2
4
+ Summary: Convert numbers across numeral systems — Roman, Chinese, Greek, Egyptian, Arabic-Indic and more.
5
+ Home-page: https://github.com/TheMadrasTechie/numly
6
+ Author: TheMadrasTechie
7
+ Author-email: sundarbala36663@gmail.com
8
+ License: MIT
9
+ Keywords: numerals,roman,chinese,greek,egyptian,arabic-indic,number,converter,tamil,mayan,babylonian,words
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: keywords
21
+ Dynamic: license
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ <p align="center">
26
+ <img src="https://raw.githubusercontent.com/TheMadrasTechie/numly/master/numly_rounded_square.svg" width="120" height="120"/>
27
+ </p>
28
+
29
+ <h1 align="center">numly</h1>
30
+
31
+ <p align="center">
32
+ A Python library to convert numbers across the world's numeral systems.
33
+ </p>
34
+
35
+ <p align="center">
36
+ <img src="https://img.shields.io/pypi/v/numly" alt="PyPI version"/>
37
+ <img src="https://img.shields.io/pypi/pyversions/numly" alt="Python versions"/>
38
+ <img src="https://img.shields.io/github/license/TheMadrasTechie/numly" alt="License"/>
39
+ <img src="https://img.shields.io/pypi/dm/numly" alt="Downloads"/>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <code>pip install numly</code>
44
+ </p>
45
+
46
+ ---
47
+
48
+ ## What is numly?
49
+
50
+ **numly** lets you convert any number between 12 different numeral systems with a single function call — from ancient Egyptian hieroglyphs to modern binary, from Mayan glyphs to English words.
51
+
52
+ ```python
53
+ import numly
54
+
55
+ numly.convert(42, "decimal", "roman") # → 'XLII'
56
+ numly.convert("XLII", "roman", "chinese") # → '四十二'
57
+ numly.to_words(1_234_567, "indian") # → 'twelve lakh thirty four thousand...'
58
+ numly.to_binary(255) # → '11111111'
59
+ numly.to_all(42) # → all systems at once
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Supported Systems
65
+
66
+ | System | Example (42) | Range |
67
+ |---|---|---|
68
+ | `decimal` | `42` | 0 – unlimited |
69
+ | `roman` | `XLII` | 1 – 3,999 |
70
+ | `arabic_indic` | `٤٢` | 0 – unlimited |
71
+ | `chinese` | `四十二` | 0 – 99,999,999 |
72
+ | `greek` | `ΜΒʹ` | 1 – 9,999 |
73
+ | `egyptian` | `𓎆𓎆𓎆𓎆𓏺𓏺` | 1 – 9,999,999 |
74
+ | `tamil` | `௪௰௨` | 0 – 9,999 |
75
+ | `babylonian` | `𒌋𒌋𒌋𒌋𒁹𒁹` | 1 – 216,000 (base 60) |
76
+ | `mayan` | `𝋂 𝋂` | 0 – 7,999 (base 20) |
77
+ | `binary` | `101010` | 0 – unlimited |
78
+ | `octal` | `52` | 0 – unlimited |
79
+ | `hex` | `2A` | 0 – unlimited |
80
+ | `words` | `forty two` | 0 – 999 trillion |
81
+
82
+ > Systems with a range limit return `None` in `to_all()` if the number is out of range.
83
+
84
+ ---
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ pip install numly
90
+ ```
91
+
92
+ Requires Python 3.8 or higher.
93
+
94
+ ---
95
+
96
+ ## Quick Start
97
+
98
+ ```python
99
+ import numly
100
+
101
+ # Numeral systems
102
+ numly.to_roman(2024) # → 'MMXXIV'
103
+ numly.to_chinese(42) # → '四十二'
104
+ numly.to_arabic_indic(2024) # → '٢٠٢٤'
105
+ numly.to_greek(999) # → 'ϠϘΘʹ'
106
+ numly.to_egyptian(1234) # → '𓆼𓍢𓍢𓎆𓎆𓎆𓏺𓏺𓏺𓏺'
107
+ numly.to_tamil(42) # → '௪௰௨'
108
+ numly.to_babylonian(61) # → '𒁹 𒁹'
109
+ numly.to_mayan(42) # → '𝋂 𝋂'
110
+ numly.to_mayan_text(42) # → '•• | ••'
111
+
112
+ # Base conversions
113
+ numly.to_binary(42) # → '101010'
114
+ numly.to_octal(42) # → '52'
115
+ numly.to_hex(255) # → 'FF'
116
+ numly.to_hex(255, prefix=True) # → '0xFF'
117
+ numly.to_base(42, 36) # → '16'
118
+
119
+ # English words
120
+ numly.to_words(1_234_567) # → 'one million two hundred thirty four thousand five hundred sixty seven'
121
+ numly.to_words(1_234_567, "indian") # → 'twelve lakh thirty four thousand five hundred sixty seven'
122
+
123
+ # Convert back to decimal
124
+ numly.from_roman('MMXXIV') # → 2024
125
+ numly.from_chinese('四十二') # → 42
126
+ numly.from_tamil('௪௰௨') # → 42
127
+ numly.from_babylonian('𒁹 𒁹') # → 61
128
+ numly.from_mayan('𝋂 𝋂') # → 42
129
+ numly.from_binary('101010') # → 42
130
+ numly.from_hex('FF') # → 255
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Universal Converter
136
+
137
+ ### `convert(value, from_system, to_system)`
138
+
139
+ Convert between **any two systems** directly — no need to go through decimal.
140
+
141
+ ```python
142
+ from numly import convert
143
+
144
+ # decimal → others
145
+ convert(42, "decimal", "roman") # → 'XLII'
146
+ convert(42, "decimal", "tamil") # → '௪௰௨'
147
+ convert(42, "decimal", "babylonian") # → '𒌋𒌋𒌋𒌋𒁹𒁹'
148
+ convert(42, "decimal", "mayan") # → '𝋂 𝋂'
149
+ convert(42, "decimal", "binary") # → '101010'
150
+ convert(42, "decimal", "hex") # → '2A'
151
+
152
+ # cross-system (no decimal step needed)
153
+ convert("MMXXIV", "roman", "chinese") # → '二千零二十四'
154
+ convert("四十二", "chinese", "greek") # → 'ΜΒʹ'
155
+ convert("ΜΒʹ", "greek", "roman") # → 'XLII'
156
+ convert("٤٢", "arabic_indic", "egyptian") # → '𓎆𓎆𓎆𓎆𓏺𓏺'
157
+ convert("101010", "binary", "hex") # → '2A'
158
+
159
+ # to decimal
160
+ convert("XLII", "roman", "decimal") # → 42
161
+ convert("FF", "hex", "decimal") # → 255
162
+ ```
163
+
164
+ ### `to_all(value, from_system="decimal")`
165
+
166
+ Convert a number to **all systems at once**.
167
+
168
+ ```python
169
+ from numly import to_all
170
+
171
+ to_all(42)
172
+ # {
173
+ # 'decimal': 42,
174
+ # 'roman': 'XLII',
175
+ # 'arabic_indic': '٤٢',
176
+ # 'chinese': '四十二',
177
+ # 'greek': 'ΜΒʹ',
178
+ # 'egyptian': '𓎆𓎆𓎆𓎆𓏺𓏺',
179
+ # 'tamil': '௪௰௨',
180
+ # 'babylonian': '𒌋𒌋𒌋𒌋𒁹𒁹',
181
+ # 'mayan': '𝋂 𝋂',
182
+ # 'binary': '101010',
183
+ # 'octal': '52',
184
+ # 'hex': '2A'
185
+ # }
186
+ ```
187
+
188
+ ---
189
+
190
+ ## English Words
191
+
192
+ Convert numbers to English words in **Western** or **Indian** system.
193
+
194
+ ```python
195
+ from numly import to_words, to_words_western, to_words_indian
196
+
197
+ # Western system (thousand → million → billion → trillion)
198
+ to_words_western(0) # → 'zero'
199
+ to_words_western(42) # → 'forty two'
200
+ to_words_western(1_000) # → 'one thousand'
201
+ to_words_western(1_000_000) # → 'one million'
202
+ to_words_western(1_234_567) # → 'one million two hundred thirty four thousand five hundred sixty seven'
203
+ to_words_western(1_000_000_000) # → 'one billion'
204
+
205
+ # Indian system (thousand → lakh → crore)
206
+ to_words_indian(0) # → 'zero'
207
+ to_words_indian(42) # → 'forty two'
208
+ to_words_indian(1_00_000) # → 'one lakh'
209
+ to_words_indian(1_234_567) # → 'twelve lakh thirty four thousand five hundred sixty seven'
210
+ to_words_indian(1_00_00_000) # → 'one crore'
211
+ to_words_indian(1_00_00_00_000) # → 'ten crore'
212
+
213
+ # or use to_words() with system parameter
214
+ to_words(1_234_567, "western") # → 'one million two hundred...'
215
+ to_words(1_234_567, "indian") # → 'twelve lakh thirty four thousand...'
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Base Conversions
221
+
222
+ ```python
223
+ from numly import to_binary, to_octal, to_hex, to_base
224
+
225
+ # Binary
226
+ to_binary(42) # → '101010'
227
+ to_binary(42, prefix=True) # → '0b101010'
228
+ from_binary('101010') # → 42
229
+
230
+ # Octal
231
+ to_octal(42) # → '52'
232
+ to_octal(42, prefix=True) # → '0o52'
233
+ from_octal('52') # → 42
234
+
235
+ # Hexadecimal
236
+ to_hex(255) # → 'FF'
237
+ to_hex(255, prefix=True) # → '0xFF'
238
+ to_hex(255, upper=False) # → 'ff'
239
+ from_hex('FF') # → 255
240
+ from_hex('0xff') # → 255
241
+
242
+ # Any custom base (2–36)
243
+ to_base(42, 2) # → '101010'
244
+ to_base(42, 8) # → '52'
245
+ to_base(42, 16) # → '2A'
246
+ to_base(255, 36) # → '73'
247
+ from_base('2A', 16) # → 42
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Ancient Numeral Systems
253
+
254
+ ### Tamil (0 – 9,999)
255
+
256
+ Ancient Tamil positional-additive system using Unicode Tamil block.
257
+
258
+ ```python
259
+ numly.to_tamil(0) # → '௦'
260
+ numly.to_tamil(10) # → '௰'
261
+ numly.to_tamil(42) # → '௪௰௨'
262
+ numly.to_tamil(1234) # → '௧௲௨௱௩௰௪'
263
+ numly.from_tamil('௪௰௨') # → 42
264
+ ```
265
+
266
+ ### Babylonian (1 – 216,000)
267
+
268
+ Base-60 cuneiform system using 𒁹 (1) and 𒌋 (10). Digits separated by spaces.
269
+
270
+ ```python
271
+ numly.to_babylonian(10) # → '𒌋'
272
+ numly.to_babylonian(42) # → '𒌋𒌋𒌋𒌋𒁹𒁹'
273
+ numly.to_babylonian(60) # → '𒁹 𒑱' (1×60 + zero)
274
+ numly.to_babylonian(61) # → '𒁹 𒁹' (1×60 + 1)
275
+ numly.to_babylonian(3661) # → '𒁹 𒁹 𒁹' (1×3600 + 1×60 + 1)
276
+ numly.from_babylonian('𒁹 𒁹') # → 61
277
+ ```
278
+
279
+ ### Mayan (0 – 7,999)
280
+
281
+ Base-20 system — one of the first civilisations to use zero.
282
+ Available in Unicode glyph form and human-readable dot/bar form.
283
+
284
+ ```python
285
+ numly.to_mayan(0) # → '𝋠'
286
+ numly.to_mayan(19) # → '𝋳'
287
+ numly.to_mayan(20) # → '𝋡 𝋠' (1×20 + 0)
288
+ numly.to_mayan(42) # → '𝋂 𝋂' (2×20 + 2)
289
+ numly.to_mayan_text(0) # → '◎' (shell = zero)
290
+ numly.to_mayan_text(7) # → '••━' (2 dots + 1 bar)
291
+ numly.to_mayan_text(42) # → '•• | ••'
292
+ numly.from_mayan('𝋂 𝋂') # → 42
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Validation
298
+
299
+ Each system has an `is_valid_*` function:
300
+
301
+ ```python
302
+ numly.is_valid_roman("XIV") # → True
303
+ numly.is_valid_roman("ABC") # → False
304
+ numly.is_valid_chinese("四十二") # → True
305
+ numly.is_valid_greek("ΜΒʹ") # → True
306
+ numly.is_valid_egyptian("𓎆𓎆𓏺𓏺") # → True
307
+ numly.is_valid_arabic_indic("٤٢") # → True
308
+ numly.is_valid_tamil("௪௰௨") # → True
309
+ numly.is_valid_babylonian("𒁹 𒁹") # → True
310
+ numly.is_valid_mayan("𝋂 𝋂") # → True
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Egyptian Symbol Breakdown
316
+
317
+ ```python
318
+ from numly import symbol_breakdown
319
+
320
+ symbol_breakdown(1234)
321
+ # {'𓆼': 1, '𓍢': 2, '𓎆': 3, '𓏺': 4}
322
+ # 1 lotus (1000) + 2 rope coils (100) + 3 heel bones (10) + 4 tallies (1)
323
+ ```
324
+
325
+ ---
326
+
327
+ ## Error Handling
328
+
329
+ numly raises clear, descriptive errors:
330
+
331
+ ```python
332
+ numly.to_roman(5000)
333
+ # ValueError: Roman numerals support 1–3999, got 5000
334
+
335
+ numly.to_roman("hello")
336
+ # TypeError: Expected int, got 'str'
337
+
338
+ numly.from_roman("XYZ")
339
+ # ValueError: Invalid Roman numeral character: 'Y'
340
+
341
+ numly.to_binary(-1)
342
+ # ValueError: Negative numbers are not supported
343
+
344
+ numly.to_words(42, "french")
345
+ # ValueError: Unknown system 'french'. Choose 'western' or 'indian'.
346
+ ```
347
+
348
+ ---
349
+
350
+ ## Full API Reference
351
+
352
+ ### Numeral Systems
353
+
354
+ | Function | Input | Output |
355
+ |---|---|---|
356
+ | `to_roman(n)` / `from_roman(s)` | `int` / `str` | `str` / `int` |
357
+ | `to_arabic_indic(n)` / `from_arabic_indic(s)` | `int` / `str` | `str` / `int` |
358
+ | `to_chinese(n)` / `from_chinese(s)` | `int` / `str` | `str` / `int` |
359
+ | `to_greek(n)` / `from_greek(s)` | `int` / `str` | `str` / `int` |
360
+ | `to_egyptian(n)` / `from_egyptian(s)` | `int` / `str` | `str` / `int` |
361
+ | `to_tamil(n)` / `from_tamil(s)` | `int` / `str` | `str` / `int` |
362
+ | `to_babylonian(n)` / `from_babylonian(s)` | `int` / `str` | `str` / `int` |
363
+ | `to_mayan(n)` / `from_mayan(s)` | `int` / `str` | `str` / `int` |
364
+ | `to_mayan_text(n)` | `int` | `str` (dots & bars) |
365
+ | `symbol_breakdown(n)` | `int` | `dict` |
366
+
367
+ ### Base Conversions
368
+
369
+ | Function | Input | Output |
370
+ |---|---|---|
371
+ | `to_binary(n, prefix)` / `from_binary(s)` | `int` / `str` | `str` / `int` |
372
+ | `to_octal(n, prefix)` / `from_octal(s)` | `int` / `str` | `str` / `int` |
373
+ | `to_hex(n, prefix, upper)` / `from_hex(s)` | `int` / `str` | `str` / `int` |
374
+ | `to_base(n, base)` / `from_base(s, base)` | `int` / `str` | `str` / `int` |
375
+
376
+ ### Words
377
+
378
+ | Function | Input | Output |
379
+ |---|---|---|
380
+ | `to_words(n, system)` | `int`, `'western'`/`'indian'` | `str` |
381
+ | `to_words_western(n)` | `int` | `str` |
382
+ | `to_words_indian(n)` | `int` | `str` |
383
+
384
+ ### Universal
385
+
386
+ | Function | Input | Output |
387
+ |---|---|---|
388
+ | `convert(value, from, to)` | `any` | `str` / `int` |
389
+ | `to_all(value, from)` | `any` | `dict` |
390
+ | `supported_systems()` | — | `list` |
391
+
392
+ ---
393
+
394
+ ## What's Coming Next
395
+
396
+ - 🔜 Negative number support
397
+ - 🔜 Locale-aware formatting (`1,000.00` vs `1.000,00`)
398
+ - 🔜 Words in more languages (Tamil, Hindi, Arabic…)
399
+ - 🔜 Numbers beyond current range limits
400
+ - 🔜 More ancient systems (Aztec, Sumerian, Greek acrophonic)
401
+
402
+ ---
403
+
404
+ ## Contributing
405
+
406
+ Contributions are welcome! Feel free to open an issue or submit a pull request.
407
+
408
+ ```bash
409
+ git clone https://github.com/TheMadrasTechie/numly.git
410
+ cd numly
411
+ pip install -e .
412
+ ```
413
+
414
+ ---
415
+
416
+ ## License
417
+
418
+ MIT License © 2026 TheMadrasTechie