fgh3966 Active Member Licensed User May 28, 2023 #1 Hello everybody How can we shift a 4-bit byte to the right and replace the empty spaces with zero, and then also do the same thing to shift to the left ? Thank
Hello everybody How can we shift a 4-bit byte to the right and replace the empty spaces with zero, and then also do the same thing to shift to the left ? Thank
Daestrum Expert Licensed User Longtime User May 28, 2023 #2 RightShift example - basically the same for LeftShift B4X: Dim value As Int = 0x48 value = Bit.And(value, 0xF0) ' not really needed but would be 0x0F for left shift to clear sign bit value = Bit.ShiftRight( value, 4) ' shift right 4 bits Upvote 0
RightShift example - basically the same for LeftShift B4X: Dim value As Int = 0x48 value = Bit.And(value, 0xF0) ' not really needed but would be 0x0F for left shift to clear sign bit value = Bit.ShiftRight( value, 4) ' shift right 4 bits