I probably should have mentioned that as a side note in the video. Yes! You absolutely can use shifting to multiply (and divide) by powers of 2! You can also combine it with adding to get other values. For example to multiply X by 10: X
@@JohnsBasement But you cannot create special routines for every circumstance by this way right? What if a x b? how to use shift + add to implement a x b?
@@aeebeecee3737 Oh... normally a general purpose shift & add function is used to do the multiplication in binary. A quick google search got me here and it looks like a good general description of it: byjus.com/maths/binary-multiplication/ It is just doing it the way we learn in grade school.. but since you only have to multiply by either 1 or 0, it is trivial. You implement it using a loop that asks if the low-bit of the multiplier is 1 and add the multiplicand to the zero-initialized product and then shift the multiplicand to the left 1 bit and the multiplier to the right one bit each time through the loop until the multiplier becomes zero.