Code archives/Algorithms/Binary string to integer

This code has not been declared by its author to be Public Domain code, and therefore should not be assumed to be so.

Download source code

Binary string to integer by Snarkbait
(Posted 25 years ago)
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