home | 163 . 202 . 244 . 253 . 355 | courses | advisees | faq | honesty | jupiter files | schedule | webpage help | unix help | c++ help | vb help | assembly help

   binary, hex and decimal

Numbers are abstract concepts that we represent with digits from a numbering system. Our number systems are positional systems where each position of a digit signifies a value based on the number base.

The base of a number system is arbitrary, except that some bases are more "natural" for some situations. Our most familiar number base is 10 (decimal), probably used because we have 10 fingers (digits).

A computer doesn't have 10 fingers (digits) - it has only two: one and zero, because it uses electronic switches that can either be ON (1) or OFF (0). So it's natural to use the base 2 system with computers. (binary number system)

Since binary is cryptic and difficult to understand as the digits increase, we use hexadecimal (base 16) as a shorthand notation. It simply groups 4 binary digits and expresses them as a single hex digit (0-9, a-f).

The following table shows how you can express the same abstract concept, a number, in three different bases: base 2, base 10 and base 16.

binary (base 2) hex (base 16) decimal (base 10)
0 0 0
1 1 1
10 (2^1) 2 2
11 3 3
100 (2^2) 4 4
101 5 5
110 6 6
111 7 7
1000 (2^3) 8 8
1001 9 9
1010 a 10 (10^1)
1011 b 11
1100 c 12
1101 d 13
1110 e 14
1111 f 15
10000 (2^4) 10 (16^1) 16
. . . . . . . . .
11111 1f 31
100000 (2^5) 20 32
. . . . . . . . .
111111 3f 63
1000000 (2^6) 40 64
. . . . . . . . .
1100011 63 99
1100100 64 100 (10^2)
. . . . . . . . .
1111111 7f 127
10000000 (2^7) 80 128
. . . . . . . . .
11111111 ff 255
100000000 (2^8) 100 (16^2) 256
. . . . . . . . .
111111111 ff 511
1000000000 (2^9) 200 512
. . . . . . . . .
1111100111 3e7 999
1111101000 3e8 1000 (10^3)
. . . . . . . . .
1111111111 3ff 1023
10000000000 (2^10) 400 1024
. . . . . . . . .
11111111111 7ff 2047
100000000000 (2^11) 800 2048
. . . . . . . . .
111111111111 fff 4095
1000000000000 (2^12) 1000 (16^3) 4096
binary hex decimal
NOTE:
Powers of 2 are: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, ...
Powers of 16 are: 16, 256, 4096, 65536, ...
Powers of 10 are: 10, 100, 1000, 10000, ...