Can anyone explain why '>>2' shift means 'divided by 4' in C codes?
问题 I know and understand the result. For example: <br> 7 (decimal) = 00000111 (binary) <br> and 7 >> 2 = 00000001 (binary) <br> 00000001 (binary) is same as 7 / 4 = 1 <br> So 7 >> 2 = 7 / 4 <br> <br> But I'd like to know how this logic is created. Can anyone elaborate on this logic ? (Maybe it's just popped up in a genius head ?) And is there any other similar logics like this ? 回答1: It didn't "pop-up" in a genius' head. Right shifting binary numbers would divide a number by 2 and left shifting