Bit shift operators in F # are documented as not performing rotation when shifting bits beyond the end of a value. You can see this in F # Interactive:
> let a = 128uy
- a << & lt 1 ;;
val a: byte = 128uy
val it: byte = 0uy
That is, we have shifted the top bit from the top of 128, indicating 0.
If F # turned the bits instead of moving them from the end, we would get 1 instead, since 1 bit in the MSB is turned to LSB .
However, if you make a small change in the second expression, you will get an amazing result:
> let a = 128uy
- a << & lt 8 ;;
val a: byte = 128uy
val it: byte = 128uy
Now, it looks like he made a complete bit-by-turn!
Why is this?
source share