convert integers to binary and vice-a-versa
Project description
A python module where a number can be converted to it’s binary bits and binary bits to number. Note: binary bits which will be recieved and provided will be in string format for early releases.
binary_parser is a simple python library where users can convert an integer to its bit string and vice versa.
Installation
pip install number-parser
number-parser requires Python 3.6+.
Usage
The library provides the following common use cases.
Converting a binary string to an integer
>>> import binary_parser >>> binary_parser.parse_to_num('1011') '11' >>> binary_parser.parse_to_num('000') '0' >>> binary_parser.parse_to_num('01') '1'
Converting an integer to its binary format
Arguments passed can be a string or an integer type.
>>> import binary_parser >>> binary_parser.parse_to_binary('7') '111' >>> binary_parser.parse_to_binary(1) '1' >>> binary_parser.parse_to_binary('0') '0'
Checking if given string is binary or integer
>>> import binary_parser >>> binary_parser.which_parser('1010') 'Input 1010 could be either binary or a number' 'binary string: 1010 number: 10' >>> binary_parser.which_parser(12) 'Input 12 is a number' 'number: 12' >>> binary_parser.which_parser('00101') 'Input 00101 could be either binary or a number' 'binary string: 00101 number: 101'
Change Log
0.0.1 (07/02/2022)
First Release
0.0.2 (08/02/2022)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for binary_parser-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb04d5834eb6a7205d2d49d60523410ac86ae843738d41327409edfa333432c0 |
|
MD5 | 3b7c1189a1b9295667b7a29409d8a706 |
|
BLAKE2b-256 | 7b815ceb390af237f1baa1da6d0de6fcdfc04d5ce5af011ac5c1c601f9d54b3e |