![]() |
Python
1.0
|
Multiplication using shifts. More...
Functions | |
def | Product (a, b) |
Multiplies two integers by using only the + operation. More... | |
def | Product2 (a, b, base=10) |
def | main (argv=None) |
Multiplication using shifts.
Thinking binary:
1011 X 11 1101 13 ---- -------- 1011 + 1*1*1011 1011 << 0 00000 0*2*1011 0000 << 1 101100 1*4*1011 1011 << 2 1011000 1*8*1011 1011 << 3 ------- -------- 10001111 143
def _01e_multbin.main | ( | argv = None | ) |
References _01d_dec2bin.input, Product(), and Product2().
def _01e_multbin.Product | ( | a, | |
b | |||
) |
Multiplies two integers by using only the + operation.
a | first factor. |
b | second factor. |
Referenced by main().
def _01e_multbin.Product2 | ( | a, | |
b, | |||
base = 10 |
|||
) |
Equivalent version, but very inneficient.
Referenced by main().