Library "libc:6"
' long int strtol (const char *__restrict __nptr, char **__restrict __endptr, int __base)
' Convert a string to a long integer.
Private Extern strtol(__nptr As String, __endptr As Pointer, __base As Integer) As Long
Public Sub Main()
Dim binario As String
binario = "11111110"
Print strtol(binario, 0, 2)
End
(12-08-2022, 17:18)cogier escribió: Print Val("%11111110")
(12-08-2022, 21:44)vuott escribió: Pero yo por curiosidad te propongo una solución más simpatica:
Public Sub Main()
Dim s As String
Dim bb As Byte[]
Dim b As Byte
Dim l As Long ' u otro tipo de dato nativo
s = "11111110"
bb = Byte[].FromString(s).Reverse()
For b = 0 To bb.Max
l += CLong((bb - 48) * (2 ^ b))
Next
Print l
End