[Gambas-user] byte to bit & bit to byte

Martin mbelmonte at belmotek.net
Sat Aug 13 17:02:37 CEST 2022


El 13/8/22 a las 8:30, Fabien Bodard escribió:
> i = val("&x11111100")
> 
> Le ven. 12 août 2022 à 16:45, Linus via User
>> Print &x11111110
>> Olivier
>>
>> Le 12 août 2022 à 10:22, vuott--- via User <user at lists.gambas-basic.org> a écrit :
>> Public Sub Main()
>>    Dim binario As String
>>    Dim num As Long   ' or other primitive datatype
>>    Dim pos As Byte
>>    binario = "11111110"
>>    Repeat
>>      num += CLong(Val(Mid(binario, Len(binario) - pos, 1)) * (2 ^ pos))
>>      Inc pos
>>    Until pos = Len(binario)
>>    Print num
>> End

I want to use bytes to indicate 8 possible groups in a team work in only 
one field of the table.
Now, thanks to your answers, I can encode and decode the byte.
Thanks to all.


More information about the User mailing list