Small python program that converts base 10 integers or fractionary numbers to bases 2-9 numbers.
Project description
base-converter
Converts base-10 numbers (integers and decimals) to bases 2–9.
Installation
pip install numerical-base-converter-nighthawk017
Usage
As a library
from base_converter import convert_number
convert_number('10', 2) # '1010'
convert_number('8', 8) # '10'
convert_number('0.5', 2) # '0.1'
convert_number('3.14', 8) # '3.11037...'
As a CLI
base-converter
# Enter the value to convert: 10
# Enter the target base (2-9): 2
# Result: 1010
API
convert_number(value_str: str, target_base: int) -> str
Converts a base-10 number string to the target base. Accepts integers ('42') and decimals ('3.14').
convert_integer_part(value: int, target_base: int) -> str
convert_fractionary_part(value_str: str, target_base: int) -> str
Lower-level functions for converting the integer and fractional parts separately.
Raises ValueError if target_base is outside 2–9 or value_str is not a valid number.
Requirements
Python >= 3.8
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 Distributions
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 numerical_base_converter-0.0.1-py3-none-any.whl.
File metadata
- Download URL: numerical_base_converter-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f7c8040f66636c539c9d9e1ce6bbb6ef07137d5ee0cb2b15674260c16be5e43
|
|
| MD5 |
10b23487d461b3b49ea20b256269596e
|
|
| BLAKE2b-256 |
5d44fb5efce75f24e9f3fcee8c2a044b083d5d12fc1ede7d66c340eb35060bb2
|