base-bcd-kit 0.1.0__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.
- base_bcd_kit-0.1.0/LICENSE +21 -0
- base_bcd_kit-0.1.0/PKG-INFO +61 -0
- base_bcd_kit-0.1.0/README.md +41 -0
- base_bcd_kit-0.1.0/pyproject.toml +27 -0
- base_bcd_kit-0.1.0/setup.cfg +4 -0
- base_bcd_kit-0.1.0/src/base_bcd_kit/__init__.py +52 -0
- base_bcd_kit-0.1.0/src/base_bcd_kit.egg-info/PKG-INFO +61 -0
- base_bcd_kit-0.1.0/src/base_bcd_kit.egg-info/SOURCES.txt +8 -0
- base_bcd_kit-0.1.0/src/base_bcd_kit.egg-info/dependency_links.txt +1 -0
- base_bcd_kit-0.1.0/src/base_bcd_kit.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Farhan Adil
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: base-bcd-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight Python utilities for Binary, Decimal, Hex, 4-bit BCD, and 8-bit ASCII conversions.
|
|
5
|
+
Author: Farhan Adil
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://binaryconverter.org
|
|
8
|
+
Project-URL: BCD Converter, https://binaryconverter.org/bcd-converter
|
|
9
|
+
Project-URL: Repository, https://github.com/farhanadilumarkhan/base-bcd-kit
|
|
10
|
+
Keywords: binary,bcd,ascii,converter,hexadecimal,number-system
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# base-bcd-kit
|
|
22
|
+
|
|
23
|
+
A lightweight, zero-dependency Python utility for converting between **Decimal, Binary, Hexadecimal, 4-bit BCD (Binary Coded Decimal), and 8-bit ASCII**.
|
|
24
|
+
|
|
25
|
+
> **Prefer an instant browser interface or offline PWA?**
|
|
26
|
+
> Try the interactive calculators at **[BinaryConverter.org](https://binaryconverter.org)**, including the **[BCD Converter](https://binaryconverter.org/bcd-converter)** and **[ASCII to Binary Converter](https://binaryconverter.org/ascii-to-binary)**.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install base-bcd-kit
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Usage
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from base_bcd_kit import (
|
|
38
|
+
dec_to_bin,
|
|
39
|
+
bin_to_dec,
|
|
40
|
+
dec_to_hex,
|
|
41
|
+
dec_to_bcd,
|
|
42
|
+
bcd_to_dec,
|
|
43
|
+
text_to_ascii_bin,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
print(dec_to_bin(42)) # '101010'
|
|
47
|
+
print(bin_to_dec("101010")) # 42
|
|
48
|
+
print(dec_to_hex(255)) # 'FF'
|
|
49
|
+
print(dec_to_bcd(25)) # '0010 0101'
|
|
50
|
+
print(bcd_to_dec("0010 0101")) # '25'
|
|
51
|
+
print(text_to_ascii_bin("Hi")) # '01001000 01101001'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Links
|
|
55
|
+
|
|
56
|
+
- **Web Calculators:** [BinaryConverter.org](https://binaryconverter.org)
|
|
57
|
+
- **Source Code:** [GitHub](https://github.com/farhanadilumarkhan/base-bcd-kit)
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT License
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# base-bcd-kit
|
|
2
|
+
|
|
3
|
+
A lightweight, zero-dependency Python utility for converting between **Decimal, Binary, Hexadecimal, 4-bit BCD (Binary Coded Decimal), and 8-bit ASCII**.
|
|
4
|
+
|
|
5
|
+
> **Prefer an instant browser interface or offline PWA?**
|
|
6
|
+
> Try the interactive calculators at **[BinaryConverter.org](https://binaryconverter.org)**, including the **[BCD Converter](https://binaryconverter.org/bcd-converter)** and **[ASCII to Binary Converter](https://binaryconverter.org/ascii-to-binary)**.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install base-bcd-kit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Usage
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from base_bcd_kit import (
|
|
18
|
+
dec_to_bin,
|
|
19
|
+
bin_to_dec,
|
|
20
|
+
dec_to_hex,
|
|
21
|
+
dec_to_bcd,
|
|
22
|
+
bcd_to_dec,
|
|
23
|
+
text_to_ascii_bin,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
print(dec_to_bin(42)) # '101010'
|
|
27
|
+
print(bin_to_dec("101010")) # 42
|
|
28
|
+
print(dec_to_hex(255)) # 'FF'
|
|
29
|
+
print(dec_to_bcd(25)) # '0010 0101'
|
|
30
|
+
print(bcd_to_dec("0010 0101")) # '25'
|
|
31
|
+
print(text_to_ascii_bin("Hi")) # '01001000 01101001'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Links
|
|
35
|
+
|
|
36
|
+
- **Web Calculators:** [BinaryConverter.org](https://binaryconverter.org)
|
|
37
|
+
- **Source Code:** [GitHub](https://github.com/farhanadilumarkhan/base-bcd-kit)
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT License
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "base-bcd-kit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Lightweight Python utilities for Binary, Decimal, Hex, 4-bit BCD, and 8-bit ASCII conversions."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Farhan Adil"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["binary", "bcd", "ascii", "converter", "hexadecimal", "number-system"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
"Topic :: Utilities",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://binaryconverter.org"
|
|
26
|
+
"BCD Converter" = "https://binaryconverter.org/bcd-converter"
|
|
27
|
+
Repository = "https://github.com/farhanadilumarkhan/base-bcd-kit"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Lightweight number system, 4-bit BCD, and 8-bit ASCII conversion utilities."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def dec_to_bin(number: int) -> str:
|
|
7
|
+
"""Convert a non-negative integer to binary string."""
|
|
8
|
+
if not isinstance(number, int) or number < 0:
|
|
9
|
+
raise ValueError("Input must be a non-negative integer.")
|
|
10
|
+
return bin(number)[2:]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def bin_to_dec(binary_str: str) -> int:
|
|
14
|
+
"""Convert a binary string to a decimal integer."""
|
|
15
|
+
clean = binary_str.strip().replace(" ", "")
|
|
16
|
+
if not clean or any(ch not in "01" for ch in clean):
|
|
17
|
+
raise ValueError("Input must contain only 0 and 1.")
|
|
18
|
+
return int(clean, 2)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def dec_to_hex(number: int) -> str:
|
|
22
|
+
"""Convert a non-negative integer to uppercase hexadecimal string."""
|
|
23
|
+
if not isinstance(number, int) or number < 0:
|
|
24
|
+
raise ValueError("Input must be a non-negative integer.")
|
|
25
|
+
return hex(number)[2:].upper()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def dec_to_bcd(number: int | str) -> str:
|
|
29
|
+
"""Convert decimal digits into 4-bit Binary Coded Decimal (BCD)."""
|
|
30
|
+
digits = str(number).strip()
|
|
31
|
+
if not digits.isdigit():
|
|
32
|
+
raise ValueError("Input must contain decimal digits (0-9) only.")
|
|
33
|
+
return " ".join(format(int(d), "04b") for d in digits)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def bcd_to_dec(bcd_str: str) -> str:
|
|
37
|
+
"""Convert 4-bit BCD nibbles back to a decimal string."""
|
|
38
|
+
clean = bcd_str.strip().replace(" ", "")
|
|
39
|
+
if not clean or len(clean) % 4 != 0 or any(ch not in "01" for ch in clean):
|
|
40
|
+
raise ValueError("BCD input must be groups of 4 binary bits.")
|
|
41
|
+
result = []
|
|
42
|
+
for i in range(0, len(clean), 4):
|
|
43
|
+
val = int(clean[i : i + 4], 2)
|
|
44
|
+
if val > 9:
|
|
45
|
+
raise ValueError(f"Invalid BCD nibble: {clean[i:i+4]}")
|
|
46
|
+
result.append(str(val))
|
|
47
|
+
return "".join(result)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def text_to_ascii_bin(text: str) -> str:
|
|
51
|
+
"""Convert ASCII text into space-separated 8-bit binary bytes."""
|
|
52
|
+
return " ".join(format(ord(ch), "08b") for ch in text)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: base-bcd-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight Python utilities for Binary, Decimal, Hex, 4-bit BCD, and 8-bit ASCII conversions.
|
|
5
|
+
Author: Farhan Adil
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://binaryconverter.org
|
|
8
|
+
Project-URL: BCD Converter, https://binaryconverter.org/bcd-converter
|
|
9
|
+
Project-URL: Repository, https://github.com/farhanadilumarkhan/base-bcd-kit
|
|
10
|
+
Keywords: binary,bcd,ascii,converter,hexadecimal,number-system
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# base-bcd-kit
|
|
22
|
+
|
|
23
|
+
A lightweight, zero-dependency Python utility for converting between **Decimal, Binary, Hexadecimal, 4-bit BCD (Binary Coded Decimal), and 8-bit ASCII**.
|
|
24
|
+
|
|
25
|
+
> **Prefer an instant browser interface or offline PWA?**
|
|
26
|
+
> Try the interactive calculators at **[BinaryConverter.org](https://binaryconverter.org)**, including the **[BCD Converter](https://binaryconverter.org/bcd-converter)** and **[ASCII to Binary Converter](https://binaryconverter.org/ascii-to-binary)**.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install base-bcd-kit
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Usage
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from base_bcd_kit import (
|
|
38
|
+
dec_to_bin,
|
|
39
|
+
bin_to_dec,
|
|
40
|
+
dec_to_hex,
|
|
41
|
+
dec_to_bcd,
|
|
42
|
+
bcd_to_dec,
|
|
43
|
+
text_to_ascii_bin,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
print(dec_to_bin(42)) # '101010'
|
|
47
|
+
print(bin_to_dec("101010")) # 42
|
|
48
|
+
print(dec_to_hex(255)) # 'FF'
|
|
49
|
+
print(dec_to_bcd(25)) # '0010 0101'
|
|
50
|
+
print(bcd_to_dec("0010 0101")) # '25'
|
|
51
|
+
print(text_to_ascii_bin("Hi")) # '01001000 01101001'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Links
|
|
55
|
+
|
|
56
|
+
- **Web Calculators:** [BinaryConverter.org](https://binaryconverter.org)
|
|
57
|
+
- **Source Code:** [GitHub](https://github.com/farhanadilumarkhan/base-bcd-kit)
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT License
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
base_bcd_kit
|