Skip to main content

Base Conversion Kit

Say Thanks! CodeCoverage Deploy static content to Pages Continuous Integrations codecov

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.

Metadata

Release files for base-conversion-kit 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for base-conversion-kit 1.0.7
File Size Uploaded
base_conversion_kit-1.0.7.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for base-conversion-kit 1.0.7
File Interpreter ABI Platform
base_conversion_kit-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / base_conversion_kit-1.0.7.tar.gz

Download URL base_conversion_kit-1.0.7.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
635ad2b5d0f361f1e1f5384312576c7fa2926db5f1195d174ede76dee7368a22
BLAKE2b-256 checksum
How to use checksums
2cba39a41c8d99ce582554d89682a0858f4e7c0fd16d3ffc608ff5a4809a0775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release files / base_conversion_kit-1.0.7-py3-none-any.whl

Download URL base_conversion_kit-1.0.7-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3fe4e8c06929e957623268d56651b33349ea9f2e2c601617a3ae92949f54a81
BLAKE2b-256 checksum
How to use checksums
4a0737b32f06bfbbe8a5469b738f71b18424b6f9cf5f25342f889777848c1747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page