dec2bin

Takes a decimal number(int or float) as parameter and returns its binary representation.


dec2bin(num)

Immediately converts any decimal number(int or float) to its binary form.

Parameters: num

Any integer or float. It can be both positive or negative.

Returns:

the binary representation of the decimal used as parameter

Here are some examples of usage of the dec2bin function:


>>> from dec2bin import *
>>> dec2bin(-44)
'-101100'

>>> from dec2bin import dec2bin
>>> dec2bin(0.375)
'.011'

>>> from dec2bin import dec2bin as db
>>> db(73.125)
'1001001.001'
>>> db(38.47) '100110.011110000101000111101011100001010001111010111'

Download link:

Python Package Index

Source code and Windows installer:

Git Hub

Copyright (C) 2016 Andre Rossi Korol
GNU GPLv3 License


Contact information:
email:
anrobits@yahoo.com.br