```
Sub ReflectByte(X As Int) As Int
Dim Y As Int = X
'bitmasks: 0x55 = 01010101 0x33 = 00110011 0x0F = 00001111
' 0xAA = 10101010 0xCC = 11001100 0xF0 = 11110000
Y = Bit.Or( Bit.ShiftLeft(Bit.And(Y, 0x55), 1), Bit.ShiftRight(Bit.And(Y, 0xAA), 1) ) 'swap alternate 1-bit blocks
Y = Bit.Or( Bit.ShiftLeft(Bit.And(Y, 0x33), 2), Bit.ShiftRight(Bit.And(Y, 0xCC), 2) ) 'swap alternate 2-bit blocks
Y = Bit.Or( Bit.ShiftLeft(Bit.And(Y, 0x0F), 4), Bit.ShiftRight(Bit.And(Y, 0xF0), 4) ) 'swap alternate 4-bit blocks (nybbles within bytes)
Return Y
End Sub
```