So I have an assignment that I have to code a function in c that uses only the bitwise operations of ~ , & , ^ , | , + , << , >> , and =. I have to use only 20 ope
The difference between logical and arithmetic shift are the bits shifted in from the left. To implement logical shift in terms of arithmetic you can do the arithmetic shift and then clear the new bits. In pseudo-code:
Using AND means you don't have to care what bits are shifted in. You just want to unconditionally set them to 0.
The question then is how to generate the mask. I'll leave that as an exercise for you.