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.
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'
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'
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'
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'
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'