Sub Activity_Create(FirstTime As Boolean)
For i = -128 To 127
Dim b As Byte = i
Log(ByteToString(b))
Log(ByteToString(Reverse(b)))
Log("****")
Next
End Sub
Sub ByteToString(b As Byte) As String
Return NumberFormat2(Bit.ToBinaryString(Bit.AND(b, 0x00FF)), 8, 0, 0, False)
End Sub
Sub Reverse(b As Byte) As Byte
Dim r As Byte
For i = 0 To 7
'get the bit at i:
Dim bt As Byte = Bit.UnsignedShiftRight(Bit.AND(b, Bit.ShiftLeft(1, i)), i)
r = Bit.OR(r, Bit.ShiftLeft(bt, 7 - i))
Next
Return r
End Sub