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

Linus olivier.cruilles at yahoo.fr
Fri Aug 12 16:44:54 CEST 2022


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 ]----

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220812/6ca3eb66/attachment.htm>


More information about the User mailing list