Reputation: 10686
Lets say I have the binary number 0b110, which is 6, and I want to multiply the number by 3, to get 18 which is 0b10010. How would I do that in Python, I tried multiplying it normally, but it didn't work...
Upvotes: 3
Views: 8454
Reputation: 500377
In [2]: 0b110 * 3
Out[2]: 18
In [3]: bin(0b110 * 3)
Out[3]: '0b10010'
Upvotes: 3