ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
531 B

  1. 10 CALL SHELL("cls")
  2. 100 LET P = 0
  3. : LET S = 0
  4. 110 INPUT "Enter binary number: ";N$
  5. 120 L = LEN (N$)
  6. : IF L=0 GOTO 300
  7. 130 FOR I=1 TO L
  8. 135 IF (N$ = "0") GOTO 1000
  9. 140 LET B$ = MID$(N$, L-I+1, 1)
  10. 150 IF NOT (B$ = "0" OR B$ = "1") GOTO 300
  11. 160 LET K = VAL(B$)
  12. 170 IF (K > 0) THEN
  13. : S = S + 2 ^ P
  14. : END IF
  15. 180 LET P = P + 1
  16. 190 NEXT
  17. 200 GOTO 310
  18. 300 PRINT "Error, invalid binary entered"
  19. : GOTO 100
  20. 310 PRINT
  21. 315 PRINT "Equals decimal ";S
  22. 320 PRINT
  23. 1000 END