I have thrown together a binary/decimal conversion app as i needed to convert between the two and wondered if other people might also.
the code is below and i have attached the source in a ZIP file, i hope someone else finds it useful
the code is below and i have attached the source in a ZIP file, i hope someone else finds it useful
B4X:
Sub decTobin(decVal As Int) As String
Dim bits As Int, dec2bin As StringBuilder
dec2bin.Initialize
Do While decVal > Power(2,bits)-1
bits=bits+1
Loop
For i =bits-1 To 0 Step -1
dec2bin.Append((Bit.and(decVal , Power(2,i)))/Power(2,i))
Next
Return dec2bin
End Sub
Sub binTodec(binVal As String) As Int
Dim i As Int, v As Int, dec As Int
i = binVal.Length
v = 1
For pos = i To 1 Step -1
If binVal.SubString2(pos-1, pos) = "1" Then dec = dec + v
v = v * 2
Next
Return dec
End Sub