# What are binary and hexadecimal number systems?

What is binary? Well, that's easy. It's a base-2 number system. We use decimal which is a base-10 number system. Also commonly used are hexadecimal (base-16) and octal (base-8).

Let's consider what happens when counting from 1 to 11 in decimal. We start at 0 and go up to 9. Once we reach the number after 9, we reset the one's digit to 0 and increment the tens digit by one. In binary, we do the same thing, except instead of happening after 9, it happens after 1. Also, instead of calling it the tens digit, we call it the twos digit, fours digit, eights digit, and on up. One of the easiest ways to convert from binary to decimal and back is to go to the most significant digit and figure out the biggest number you can make using that in the incoming number system.

If you look at 1001 in binary, you know 1000 is 8. So now you have 8 in decimal and 0001 in binary. Well, 0001 in binary is 1 in decimal, so you have 9 as your decimal answer. If you want to convert 18 to decimal, you know there is a 16s spot in decimal. That's 00010000. That leaves you with 2 in decimal, 00010000 in binary. 2 in binary is 0010, which gives you 00010010 in binary.

Why do I always do binary in groups of 4 bits? It has to do with computing and hexadecimal notation. Electrical engineers and computer science guys tend to do that by habit. It's a good habit, in my opinion. Before I move on to hex, I want to talk about Binary Coded Decimal real quick. BCD is how we rapidly represent a decimal number as a binary number to put it on a 7 segment display.

In Binary Coded Decimal, you represent each decimal digit as a binary number. Instead of 12 in decimal being 00011000, we call it 0001 0010. Note that there's a space between the first 4-bit segment and the second 4-bit segment. If you see a binary clock, it's probably outputting in BCD. Very few of them output in direct binary, which is disappointing. Now you can lord over your nerd friends that their binary clock isn't true binary. King of the Geeks, indeed. In addition to standard binary and BCD, there are also one's complement, two's complement, and gray code binary counting schemes. I'll discuss those in another article when we delve into transistor optimization algorithms and how to subtract numbers without subtraction.

In hexadecimal, we confuse things by needing more symbols to represent the number after 9. We use the alphabet up to F. 1A in hexadecimal is 26 in decimal, and 11010 in binary.

At this point, you're probably thinking, "Who cares? This is for the nerds." Well, you're right, except you're the one that clicked on this article. Binary is important because it is the easiest way to pass data electronically. To pass data, you can pass it as a series of "on" and "off" voltage pulses. Suppose you want to pass the hexadecimal code for 1A (which is an eight-bit number that could correspond to a command to the processor). In that case, you will pass the binary equivalent (technically, you'd shift the voltage of a carrier wave on each clock pulse so the machine can differentiate between 001 and 011, as they'd look the same otherwise, but that's another topic entirely).