Code archives/Algorithms/Binary string to integer

This code has been declared by its author to be Public Domain code.

Download source code

Binary string to integer by Snarkbait2002
Converts a string created with bin$ back to an integer.
Function bin2int(this$)
	thisint = 0
	blen = Len(this$)
	For a = 1 To blen
		ibit = Int(Mid$(this$,a,1))
		If ibit thisint = thisint + (ibit * (2^(blen - a)))
	Next
	Return thisint
End Function

Comments

None.

Code Archives Forum