Binary & Hexidecimal Numbering Systems

It is time to abandon your reliance on the base 10 numbering system. It is after all a human construct that probably is based on the number of fingers most people have. Mathematics is perfectly happy with numbering systems based on different numbers of digits. In electrical engineering and computer science, we take advantage of this fact and use the binary numbering system to represent logic states. The binary numbering system is base 2 and just uses the digits 0 and 1.

Binary is base 2 and uses just 0 and 1

We also use hexidecimal, which is base 16, but this is really just used as shorthand for binary as you will see. With hexidecimal we need 16 digits, and these are represented by 0-9 followed by A-F.

Hexideciaml is base 16 and uses 0-9 and A-F

Decimal Numbering System (Base 10)

In order to understand different numbering systems and how to convert from one to another, we need to break down and understand our native base 10 system. Base 10 numbering system means that each position in a number can be one of ten different digits. It also means that the total value of a number in base 10 is the sum of the digits in each position multiplied by powers of 10 in ascending order from right to left starting with power of 0. Below is the number two-thousand, six hundred and fourteen with powers of ten positions identified.

2614
103102101100

The value of this base 10 number is 2*103 + 6*102 + 1*101 + 4*100, which is 2*1000 + 6*100 + 1*10 + 4*1. So, you can see that the base ten numbering system means that each position is an amount of a power of 10 that ascends from right to left. And, because each postion represents a power of 10, the total number of values in any position is 10. If you allowed 11 values in the 101 position, for example, then the next position could not be 102, because 11*101 is more than 1*102. Note that 10*101 is 1*102. So, there can only be 10 possible values in each position of a base 10 number.

Binary Numbering System (Base 2)

The binary numbering system is base 2, and each position in a binary number represents the amount of a power of 2 starting with power of 0 and ascending from right to leftt. It is like base 10, except change powers of 10 to powers of 2, and there are 2 possible values in each number position instead of 10. Here is an example number:

1010
23222120

In order to convert this number to decimal (base 10) perform the powers of 2 multiplications in base 10 for each position, multiply that by the value in that position, and sum it up. The number above would be 1*8 + 0*4 + 1*2 + 0*1 = 10 in decimal.

When writing a binary number, we often add a lower case b to the end of the number to make it clear that it is a binary number and not decimal, because 1010 is also a valid decimal number. So, we would write 1010b to be clear.

Hexidecimal Numbering System (Base 16)

The hexidecimal numbering system is base 16, and each postion in a hex number has 16 possible values. There are only ten numeric characters in the English language, 0-9, so in addition we use A-F to represent values 10-15.

A7E4
163162161160

This hexidecimal number can be converted to decimal by following the same process used for binary number conversion, except ou need to replace the alpha characters with their numeric values. 10*4096 + 7*256 + 14*16 + 4*1 = 42980 in decimal. You can see that hexidecimal can represent alot of values with just a few digits. We denote a hexidecimal number with a lower case h at the end or more commonly with a 0x at the beginning. So, we would write A7E4h or 0xA7E4 to be clear.

Binary is the numbering system we need to represent the two logic states: false represented by 0, and true represented by 1. Hexidecimal is used extensively as a shorthand for binary. Because it is base 16 with 16 being a power of 2, conversion from binary to hex is clean. All the possible values in a 4 digit binary number can be represented by a 1 digit hex number using all its possible values. A 4 digit binary number can represent values 0-15 (decimal), and a 1 digit hex number can represent values 0-15 (decimal).

To convert from binary to hex, so can use the same process as above, but the numbers being multiplied and added need to be hex numbers. For example, 10010b = 1*24 + 0*23 + 0*22 + 1*21 + 0*20 = 1*10 + 0*8 + 0*4 + 1*2 + 0*1 = 0x12. Note that each number is in hex, and the first term, 1*10, would be 1*16 in decimal. In pactice, I think most folks convert from binary to decimal and then from decimal to hex. Something like: 10010b has a 16 plus a 2 which is 18. That’s more than 16 and less than 32, so the second position has a 1 which is 16 leaving 2, so 0x12 is the answer.

Next: Binary Math