Perform operations with numbers in different bases
Project description
Base Conversion Kit
The Base Conversion Kit is a Python package designed to simplify number operations across different bases. Whether you're working with binary, octal, decimal, or hexadecimal numbers, this package provides convenient functions for conversions and basic arithmetic operations.
Installation
You can install the Base Conversion Kit using pip
:
pip install base-conversion-kit
Usage
Converting Numbers
The package offers a flexible function for converting numbers from any base to another:
from base_conversion_kit import convert_to_base_n, convert_base
# Convert a decimal number to binary
binary_result = convert_to_base_n(42, 2)
print(f"Binary representation: {binary_result}")
# Convert a hexadecimal number to octal
octal_result = convert_base("1A", 8, 16)
print(f"Octal representation: {octal_result}")
Performing Arithmetic Operations
Performing arithmetic operations on numbers from different bases is seamless:
from base_conversion_kit import multiply_numbers, add_numbers, subtract_numbers
# Multiply two binary numbers
result_binary = multiply_numbers("101", "110", 2)
print(f"Binary multiplication result: {result_binary}")
# Add two decimal numbers
result_addition = add_numbers(15, 7, 10)
print(f"Decimal addition result: {result_addition}")
# Subtract two hexadecimal numbers
result_subtraction = subtract_numbers("1A", "B", 16)
print(f"Hexadecimal subtraction result: {result_subtraction}")
Examples
Example 1: Adding Binary Numbers
from base_conversion_kit import add_numbers
result = add_numbers("101", "110", 2)
print(f"Binary addition result: {result}")
Example 2: Converting and Adding
from base_conversion_kit import convert_to_base_n, add_numbers
# Convert decimal numbers to binary and add
binary_sum = add_numbers(
convert_to_base_n(10, 2),
convert_to_base_n(5, 2),
2
)
print(f"Binary sum: {binary_sum}")
Read The Docs
More info can be found here
Contributing
Feel free to contribute to the development of the Base Conversion Kit. If you encounter issues, have suggestions, or want to add features, please submit a pull request or open an issue on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
File details
Details for the file base_conversion_kit-1.0.7.tar.gz
.
File metadata
- Download URL: base_conversion_kit-1.0.7.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 635ad2b5d0f361f1e1f5384312576c7fa2926db5f1195d174ede76dee7368a22 |
|
MD5 | 6e48d251f2ca78515cfc36d4d266f42a |
|
BLAKE2b-256 | 2cba39a41c8d99ce582554d89682a0858f4e7c0fd16d3ffc608ff5a4809a0775 |
File details
Details for the file base_conversion_kit-1.0.7-py3-none-any.whl
.
File metadata
- Download URL: base_conversion_kit-1.0.7-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3fe4e8c06929e957623268d56651b33349ea9f2e2c601617a3ae92949f54a81 |
|
MD5 | ebbb2175d4d9094cab4539a704a49c07 |
|
BLAKE2b-256 | 4a0737b32f06bfbbe8a5469b738f71b18424b6f9cf5f25342f889777848c1747 |