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

vuott at tutanota.com vuott at tutanota.com
Fri Aug 12 16:22:56 CEST 2022


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

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


More information about the User mailing list