BinPy.Operations package

Submodules

BinPy.Operations.operations module

class BinPy.Operations.operations.Operations[source]

This class implements the primary arithmetic binary functions ADD, SUB, MUL, DIV, COMP(complement). Inputs are in the form of unsigned integers. Negative numbers will have - sign.

ADD(input1, input2)[source]

This function implements the binary addition It takes two binary number and gives their sum How to use:

>>> opr = Operations()
>>> opr.ADD('1100','0001')
'1101'
COMP(input1, option)[source]

This function gives the complement of the input Note: In this case the input is put in the form of signed/unsigned number It takes two parameters, number to be complemented and the nth complement you want. How to use:

>>> opr = Operations()
>>> opr.COMP('1000','1')
'0111'
DIV(input1, input2)[source]

This function implements the binary division It takes two binary number and gives their quotient How to use:

>>> opr = Operations()
>>> opr.DIV('1000','0010')
'100'
MUL(input1, input2)[source]

This function implements the binary multiplication It takes two binary number and gives their product How to use:

>>> opr = Operations()
>>> opr.MUL('1100','0100')
'110000'
SUB(input1, input2)[source]

This function implements the binary subtraction It takes two binary number and gives their difference How to use:

>>> opr = Operations()
>>> opr.SUB('1100','0100')
'1000'
static binToDec(number)[source]

This function converts binary number into decimal number How to use:

>>> Operations.binToDec('1001')
>>> 9
static decToBin(number)[source]

This function converts positive decimal number into binary number How to use:

>>> Operations.decToBin(12)
>>> 1100

Module contents

Table Of Contents

Previous topic

BinPy.Gates package

Next topic

BinPy.Sequential package

This Page