[Gambas-user] byte to bit & bit to byte
Fabien Bodard
gambas.fr at gmail.com
Sat Aug 13 08:30:10 CEST 2022
Hi,
i = val("&x11111100")
Le ven. 12 août 2022 à 16:45, Linus via User
<user at lists.gambas-basic.org> a écrit :
>
> Or more simple:
>
> Print &x11111110
> 254
>
> Olivier
>
> Le 12 août 2022 à 10:22, vuott--- via User <user at lists.gambas-basic.org> a écrit :
>
> ...maybe:
>
> 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
>
>
>
>
>
> 12 ago 2022, 15:57 da mbelmonte at belmotek.net:
>
> Hello.
> As you know to convert a byte number into bits is done like this:
> Bin(254)
> The result is:
> 11111110
>
> But how do you get 254 from 11111110 ?
>
> Regards
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
--
Fabien Bodard
More information about the User
mailing list