IronRocket / pybit-binary

binary_hex_decimal converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is it?

Pybit is a library written in python that allows you to convert binary to decimal, binary to hex. One of its key features is bit arrays.

Conversions

str->bool_tuple

print("String -> Bool_tuple:",pybit.str_binary_to_bool("1010"))

bool_tuple -> str

print("Bool_tuple -> string:",pybit.bool_to_str_binary((True,False,True,True)))

binary -> decimal

print("Binary -> Decimal:",pybit.binary_to_decimal("1010"))

decimal -> binary

print("Decimal -> Binary",pybit.decimal_to_binary(10))

Binary -> Hex

print("Binary -> Hex",pybit.binary_to_hex("1010"))
#Alternatives:
print("Using built in funtion",hex(pybit.binary_to_decimal((True,False,True))))

Bit Array

x = pybit.bitarray()


x.appendbits((True,False))

print("Tuple containing two bits:",x.raw_data())

About

binary_hex_decimal converter

License:MIT License


Languages

Language:Python 100.0%