Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numerical_base_converter-0.0.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numerical_base_converter-0.0.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file numerical_base_converter-0.0.2.tar.gz.

File metadata

  • Download URL: numerical_base_converter-0.0.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for numerical_base_converter-0.0.2.tar.gz
Algorithm Hash digest
SHA256 af514170a0b6480d238edf43e67cd2eff23abcfcee9c59cde6149825c85aa5b6
MD5 b1e8a351140275f13e9d62cbd6151c8a
BLAKE2b-256 372721653dde12bfdfa0edc1a55da66a0dc27fafbee78d62433cddf0b844aaca

See more details on using hashes here.

File details

Details for the file numerical_base_converter-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for numerical_base_converter-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14550e0aa1686b7295b4119c7631dd126bd2c9ab9d2871ab82508cae80b26097
MD5 99dc49b334042a09e26e8553bf8d0615
BLAKE2b-256 56b1f76dd0cbb01c1a8967d3498a830ad4b0fa42b6938489e6a148c86ead30c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page