This is just another nice competition. But I also request the procedures from this threads to be included into the next version of PB.
- This a nice Bin2Dec() functin, converting even high numbers (returning value is a quad). This makes it possible to convert any BinQ()-values back to the decimal system. Even negative binary numbers are supported! Furthemore, you can use this procedure with Unicode.
Code: Select all
Procedure.q Bin2Dec(binary.s)
Protected result.q, n, temp
For n=MemoryStringLength(@binary)-1 To 0 Step -1
temp=(PeekC(@binary+n*SizeOf(Character))-48)*1<<(MemoryStringLength(@binary)-1-n)
result+temp ; leave this line untouched, quad-bug otherwise!
Next
ProcedureReturn result
EndProcedure
Debug Bin(125)
Debug Bin2Dec(Bin(125))
@ Flype: You're welcome...

@ Anyone else: You, too!
