Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 21 December 2012 - 11:01 AM

In C and C++, shifting an N-bit number by N or more bits (so a 32-bit number by 32 or more bits) is undefined behavior (thus, shifting by 32 can do anything, from crash to having no effect) (if you really need to shift by 32, you can shift by 16, and then again by 16). In x86 assembly, there are only 5 physical wires used when doing the shift, so you can say the number is "AND-ed with 31," and only the low 5 bits of the number are used when shifting (thus, shifting by 32 is really shifting by (32 & 31) which is 0).


#1Cornstalks

Posted 21 December 2012 - 11:00 AM

In C and C++, shifting an N-bit number by N or more bits (so a 32-bit number by 32 or more bits) is undefined behavior (thus, shifting by 32 can do anything, from crash to having no effect). In x86 assembly, there are only 5 physical wires used when doing the shift, so you can say the number is "AND-ed with 31," and only the low 5 bits of the number are used when shifting (thus, shifting by 32 is really shifting by (32 & 31) which is 0).


PARTNERS