Understanding Hexadecimal & Binary Number Systems
Hexadecimal Number System
The hexadecimal number system, or base 16, stands in for four binary bits at a time. It needs sixteen symbols to do that: the digits 0 to 9 for the values zero through nine, and the letters A to F for the values ten through fifteen. Because each position is a power of 16, the digits climb in value much faster than in decimal, which is why compact strings like FF can describe an entire byte of data.
Consider the hexadecimal number "5B" and how it unpacks into binary:
- The rightmost digit (B) , which stands for the value 11, is the binary equivalent of 1011.
- The leftmost digit (5) , which stands for the value 5, is the binary nibble 0101.
Join the two parts together to get 0101 1011, then drop the leading zero to leave 1011011.
Therefore, the hexadecimal number (5B)16 is equivalent to the binary value (1011011)2, which itself equals the decimal value (91)10.
Hexadecimal numbers can carry a fractional part too. Take 2F.4, for an example. The integer part 2F in binary will be (2 → 0010, F → 1111), which combine to 00101111 and then simplify to 101111. The fractional digit .4 works with negative powers of 16, specifically 16-1, or one sixteenth - giving 4 × 1/16 = 0.25, which is written as .01 in binary. The converter reports the full result as 101111.01.
Therefore, the hexadecimal number (2F.4)16 is equivalent to the binary value (101111.01)2.
Binary Number System
The binary number system, or base 2, is the language of the machine. It uses only two symbols, 0 and 1, which map neatly onto the two states of a circuit: off and on. Each position in a binary number is a power of two, starting at 20 on the right and doubling as you move left. The binary number "110101" can be read like this:
- The rightmost digit (1) is in the one's place, (1 * 1 = 1)
- The next digit (0) is in the two's place, (0 * 2 = 0)
- The next digit (1) is in the four's place, (1 * 4 = 4)
- The next digit (0) is in the eight's place, (0 * 8 = 0)
- The next digit (1) is in the sixteen's place, (1 * 16 = 16)
- The leftmost digit (1) is in the thirty-two's place, (1 * 32 = 32)
Adding those together, (1 + 0 + 4 + 0 + 16 + 32) = (53)10, which is written as (35)16 in hexadecimal.
The key idea that makes this whole page possible is a simple one: since 16 = 24, each hexadecimal digit always corresponds to exactly four binary bits. Learn those sixteen four-bit patterns and you can read binary written in hex almost as easily as you read text.