Dim b As Byte
b = 23
LogByte(b)
b = SetBit(b, 7, True)
LogByte(b)
b = SetBit(b, 0, False)
LogByte(b)
Sub LogByte(b As Byte)
Log(NumberFormat2(Bit.ToBinaryString(Bit.And(0xff, b)), 8, 0, 0, False))
End Sub
Sub SetBit(b As Byte, index As Int, on As Boolean) As Byte
If on Then
Return Bit.Or(b, Bit.ShiftLeft(1, index))
Else
Return Bit.And(b, Bit.Not(Bit.ShiftLeft(1, index)))
End If
End Sub