'===========================================================================
' Subject: COUNTING BINARY NUMBERS            Date: 06-08-96 (12:44)       
'  Author: Martin Lindhe                      Code: QB, QBasic, PDS        
'  Origin: m-35728@mailbox.swipnet.se       Packet: BINARY.ABC
'===========================================================================
' Here is a algoritm for counting binary numbers.

' 128 64 32 16 8 4 2 1      ; this is the numbers used
'   1  0  0  1 1 0 0 1      ; and here is the binary number
' 128 + 16 + 8 + 1 = 153    ; if you add the numbers above the 1's you
'                           ; will get the correct ascii number.
' That means: 10011001 = 153

' This routine was written by Martin Lindhe, contact me with e-mail at
' m-35728@mailbox.swipnet.se

Tmp = 1
Bin$ = "10011001"

FOR a = LEN(Bin$) TO 1 STEP -1
    Temp$ = MID$(Bin$, a, 1)
    IF Temp$ = "1" THEN Answer = Answer + Tmp
    Tmp = Tmp * 2
NEXT
PRINT Bin$; " is"; Answer; "in ascii."

