Skip to content

Instantly share code, notes, and snippets.

@LightningStalker
Last active August 6, 2026 08:37
Show Gist options
  • Select an option

  • Save LightningStalker/d9d16857fe748bc0045b6c5f44fa5143 to your computer and use it in GitHub Desktop.

Select an option

Save LightningStalker/d9d16857fe748bc0045b6c5f44fa5143 to your computer and use it in GitHub Desktop.
Applesoft Basic convert decimal to hex
0 REM Convert Decimal to Hexa-decimal
10 TBL$ = "0123456789abcdef"
20 DIM R%(8)
30 HOME : PRINT CHR$ (13)" Enter 0 to quit"
40 PRINT
50 INPUT " Decimal# ?";N
60 IF N = 0 THEN PRINT CHR$(4)"BYE"
70 IF N > 4294967295 GOTO 2000
80 IF N < 0 GOTO 3000
90 IF N <> INT(N) GOTO 4000
100 S = S + 1
110 Q = N / 16
120 M = INT(Q)
130 R%(S) = (Q - M) * 16 + 1
140 N = M
150 IF N > 0 GOTO 100
200 PRINT "= $";
210 PRINT MID$(TBL$, R%(S), 1);
220 S = S - 1
230 IF S = 0 GOTO 300
240 GOTO 210
300 PRINT CHR$(13)
310 GOTO 50
1000 PRINT "ERROR: ";
1010 RETURN
2000 GOSUB 1000
2010 PRINT "TOO BIG"
2020 GOTO 40
3000 GOSUB 1000
3010 PRINT "NEGATIVE"
3020 GOTO 40
4000 GOSUB 1000
4010 PRINT "HAS.FRACTION"
4020 GOTO 40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment