base 2 / base 10 / base 16 jbwyatt.com
In base 2 (binary), the place values for 8 bits UNSIGNED are: 128 64 32 16 8 4 2 1 --- -- -- -- - - - - 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 Using the unsigned binary number system we know: 1 is 2^0 = 1 10 is 2^1 = 2 100 is 2^2 = 4 1000 is 2^3 = 8 etc.. 0001 1011 => 16 + 8 + 2 + 1 = 27 1000 0000 => 128 0100 0011 => 64 + 2 + 1 = 67 We also know that in n bits, we can only represent 2^n things. So with 8 bits we can represent 2^n or 256 things which, in unsigned binary, is 0-255.

HEX to decimal/binary     DECIMAL to binary/decimal     BINARY to hex/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 a number, in three different bases: base 2, base 10 and base 16.

unsigned 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
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, ...
valid xhtml 1.0