29. Hexadecimal-Binary


General Description

This program is for computer scientists only in that it is a time-based tester for binary to hexadecimal and viceversa. Hexadecimal as such is on very few of the syllabuses for 'O' level and even at 'A' level one could avoid learning it. Nevertheless for machine code work its knowledge is essential. There are calculators today that do decimal/hex conversions but few that do binary/hex conversions. This runs on a Model A.
   For the uninitiated this is how to do a conversion:
   Consider the following binary number:   1100
   Decimal for each binary position:   8421
This means the binary number is made up of 1 * 8 and 1 * 4, which is 12.
   However hexadecimal digits are as follows (the decimal equivalents are underneath):
  
1 2 3 4 5 6 7 8 9 F
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
This means that '1 1 0 0' can be written as 'C' in hexadecimal counting.
   As hexadecimal counting is to base 16, the decimal number 28 is '1C' in hex. Confused . . . ??? Of course not. Actually, like all counting systems it's easy when you use it regularly, and like all counting systems there are short cuts. If you use the program, you may need to find them to beat the clock!

Detailed Description

   Lines 10-230 This is the main structure. Auto repeat is turned off and the cursor disconnected. The sound is defined and the three main procedures are called.
   240-380 This is the title page for the game. The brackets after the CHR$ are not strictly necessary but are kept for lucidity.
   400-520 Only one hex digit is considered. Beware - you will find a computed restore at line 430, so DO NOT RENUMBER the program.
   530-900 The RND in line 640 gets a random number from 0-15 rather than 1-16. The value D determines the number of digits to be collected, hex or binary. The characters collected are added into a string (line 780). There is no delete facility. The result is checked at line 850 after a carriage return which you must enter after all the digits have gone in.
   910-1250 The 'right' and 'wrong' procedures. The clock is a fast digital clock in double size characters.
   1270-1650 Nothing surprising here. The cursor etc. is re-enabled before finishing. To extend the program to two hex digits would be a relatively easy extension - have a go.

Educational Notes

This program cannot really be considered 'educational' except in the practice it gives against the clock. However its graphics are fun, the clock nicely displayed and it exercises my dying grey matter as it will yours.