Send Close Add comments: (status displays here)
Got it!  This site "creationpie.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Counting: bases 2, 10, and 16
by RS  admin@creationpie.com : 1024 x 640


1. Base two numbers
Here are the base 2 numbers from 0d to 15d.
0000 0100 1000 1100 0001 0101 1001 1101 0010 0110 1010 1110 0011 0111 1011 1111

You need to know these 16 numbers in base 2.

2. Create a list
The hard way to learn the first 16 numbers in base 2 is to memorize them.

The easier way, and what I do, is to write down the list starting at 0000 and ending at 1111.

3. Adding by one
To help you see the pattern, here is the sequence where 1 is added to each binary number starting at 0000.
0000 0100 1000  1100 +  1 +  1 +  1  +  1 ---- ---- ----  ---- 0001 0101 1001  1101 0001 0101 1001  1101 +  1 +  1 +  1  +  1 ---- ---- ----  ---- 0010 0110 1010  1110 0010 0110 1010  1110 +  1 +  1 +  1  +  1 ---- ---- ----  ---- 0011 0111 1011  1111 0011 0111 1011  1111 +  1 +  1 +  1 +   1 ---- ---- ---- ----- 0100 1000 1100 10000


4. Numbers from 0 to 15
Here is the list from 0000b to 1111b.
10 16     2    10 16     2 0d 0h 0000b    8d 8h 1000b 1d 1h 0001b    9d 9h 1001b 2d 2h 0010b   10d Ah 1010b 3d 3h 0011b   11d Bh 1011b 4d 4h 0100b   12d Ch 1100b 5d 5h 0101b   13d Dh 1101b 6d 6h 0110b   14d Eh 1110b 7d 7h 0111b   15d Fh 1111b


5. Base 2 bits
The bits of a byte can be numbered from 0 to 7, just as post office mailboxes can have numbers. Each box can contain a 0 or a 1.
  7   6   5   4   3   2   1   0 --------------------------------- | ? | ? | ? | ? | ? | ? | ? | ? | ---------------------------------


6. Binary numbers from 0 to 15
So, Ch is 1100b is 1*8 + 1*4 + 0*2 + 0*1 is 12d.
dec   bin hex base 2 exponential notation  0d 0000b  0h 0*23 + 0*22 + 0*21 + 0*20  1d 0001b  1h 0*23 + 0*22 + 0*21 + 1*20  2d 0010b  2h 0*23 + 0*22 + 1*21 + 0*20  3d 0011b  3h 0*23 + 0*22 + 1*21 + 1*20  4d 0100b  4h 0*23 + 1*22 + 0*21 + 0*20  5d 0101b  5h 0*23 + 1*22 + 0*21 + 1*20  6d 0110b  6h 0*23 + 1*22 + 1*21 + 0*20  7d 0111b  7h 0*23 + 1*22 + 1*21 + 1*20  8d 1000b  8h 1*23 + 0*22 + 0*21 + 0*20  9d 1001b  9h 1*23 + 0*22 + 0*21 + 1*20 10d 1010b  Ah 1*23 + 0*22 + 1*21 + 0*20 11d 1011b  Bh 1*23 + 0*22 + 1*21 + 1*20 12d 1100b  Ch 1*23 + 1*22 + 0*21 + 0*20 13d 1101b  Dh 1*23 + 1*22 + 0*21 + 1*20 14d 1110b  Eh 1*23 + 1*22 + 1*21 + 0*20 15d 1111b  Fh 1*23 + 1*22 + 1*21 + 1*20


7. Magic numbers
A magic number is a number that appears in many places as if it has some special type of meaning.

Many magic numbers in computers are actually base 2 numbers of the form 2n or 2n-1.

8. Magic numbers

  n     2n  2n  0d     1d  0000000000000001b  1d     2d  0000000000000010b  2d     4d  0000000000000100b  3d     8d  0000000000001000b  4d    16d  0000000000010000b  5d    32d  0000000000100000b  6d    64d  0000000001000000b  7d   128d  0000000010000000b  8d   256d  0000000100000000b  9d   512d  0000001000000000b 10d  1024d  0000010000000000b 11d  2048d  0000100000000000b 12d  4096d  0001000000000000b 13d  8192d  0010000000000000b 14d 16384d  0100000000000000b 15d 32768d  1000000000000000b 16d 65536d 10000000000000000b

Notice that the 1 moves to the left one place when the number is multiplied by 2 (in base 2). This is similar to the number 12 multiplied by 10 being 120 in base 10.

9. Magic numbers

  n   2n-1 2n-1  1d     1d 0000000000000001b  2d     3d 0000000000000011b  3d     7d 0000000000000111b  4d    15d 0000000000001111b  5d    31d 0000000000011111b  6d    63d 0000000000111111b  7d   127d 0000000001111111b  8d   255d 0000000011111111b  9d   511d 0000000111111111b 10d  1023d 0000001111111111b 11d  2047d 0000011111111111b 12d  4095d 0000111111111111b 13d  8191d 0001111111111111b 14d 16383d 0011111111111111b 15d 32767d 0111111111111111b 16d 65535d 1111111111111111b


10. Base ten comparison

n    10n 10n 0     0d 00001d 1    10d 00010d 2   100d 00100d 3  1000d 01000d 4 10000d 10000d


11. Base ten comparison

n 10n-1  10n-1 1    9d 00009d 2   99d 00099d 3  999d 00999d 4 9999d 09999d


12. Excel example
Excel spreadsheetAn earlier Excel version had the following limitations, much later increased. The column after Z is AA, then AB, etc. This is a base 26 representation where A is column 1, I is column 9, V is column 22, Z is column 26, AA is column 27, etc. Thus, column IV is
9*26 + 22 = 234 + 22 = 256.

Often, software limits picked by software developers correspond to the above magic numbers, either 1 to 2n or 0 to 2n-1.

13. Powers of 2
Here is the idea behind the NCAA basketball tournament. So, for a n-round tournament, you start with 2n teams so that after n rounds, you have 2n-n = 20 = 1 team left.

Note: To have more than 64 teams in the tournament, one must add another level for some of the teams.


14. End of page

by RS  admin@creationpie.com : 1024 x 640