What's happening here is that F# is doing modular arithmetic on the value on the right hand side of the bit shift operator before doing the shift. For an unsigned byte, it uses mod
8, since there are 8 bits in an F# byte. Since 8 mod
8 is 0, it is not shifting the bits in the byte at all.
You can see this more clearly if you play with the values a bit:
> let a = 4uy - a <<< 1;; val a : byte = 4uy val it : byte = 8uy > a <<< 9;; val it : byte = 8uy > a <<< 17;; val it : byte = 8uy
We get the same result in all three cases because they are equivalent expressions in mod
8.
The same thing happens with right-shift (>>>
), and the behavior isn't limited to bytes.