What Are the Differences Between Binary, Decimal and Hexadecimal?

You and I grew up counting from one to ten. Computers, however, count a little differently. They use a different numeral system, called binary, to keep track of data. But what’s that mean, and what’s the point of it all?

decimal-binary-hexadecimal-counting

All the major number systems in the world are “positional.” This means that the value of a number is determined by where in the number it appears. We call this the “place” value, and it helps determine the magnitude of a number. For example, the decimal system we’re all familiar with uses ones, tens, hundreds and thousands places to indicate how much a single “2” is worth. If “2” is in the hundreds place (as in “200”), its value is higher than the same 2 in the ones place (as in “2”).

It wasn’t always like this, though. This way of representing value is a somewhat modern invention. It requires the use of zero as a placeholder, and zero was only invented about 4000 years ago. That’s why older number systems like Roman numerals and Egyptian hieroglyphics don’t use place. Instead, you add up the value of all the “digits” to arrive at the final value.

Using this basic concept of positional value, we’ve created different numeral systems or ways of writing numbers. Numeral systems are named for the number of increments per place. When we say increments, we mean how many times you can increase the value of a single place before “carrying” that value into the next place. For example, in base-ten we can increment the ones place nine times, with ten different digits (counting zero), before we have to carry its value over to the ones place.

decimal-binary-hexadecimal-comparison

As a kid, you were taught to count on your fingers. Ten fingers, ten numbers. To count higher than ten you might hold down one finger while counting up on the others. This is the basis of the base-ten, or decimal, number system. It’s the number system that you use every day, and it’s the basis of most folks understanding of the numerical world.

Computers can’t use base-ten, however. The hardware required to represent a base-ten value at the hardware level would be enormously complex. Instead, computers use binary, or base-two, to count. In binary, there are only two numbers: one, and zero. Each “place” also has different values. The lowest place is ones, then twos, fours, eights, sixteens and so on. The value of each place is twice the value of the previous place. To evaluate a binary number’s decimal equivalent, multiply each number by its place value and add all the results together. This is actually the same thing you do when you evaluate a base-ten number, but you do it so quickly you overlook the process.

binary-place-values

Hexadecimal is different from binary and decimal. It uses base-sixteen, meaning that there are sixteen different digits that can appear in a single place. Since we only have ten numerals in our shared language, we use the first six Latin letters (A, B, C, D, E, F) to indicate digits 10 through 15. You might recognize this format from color codes used in web design. When it’s used in computing, it’s often prefixed with 0x to indicate that the following string is to be interpreted as a hexadecimal number. Each place value is sixteen times larger than the previous place value, starting with the ones place.

hexadecimal-place-values

It would certainly be convenient if we could use one numeral system for everything. Unfortunately, each numeral system has its own purpose, so we’re stuck using more than one.

Decimal is the most familiar for human operators, and it’s shared by almost every culture on Earth. That makes it the standard counting scheme for human communication. No surprise there.

Computers can’t count in decimal, however. Their circuits can only represent one of two states: ON or OFF. That makes them a natural fit for binary, which has two states: one and zero. Zero, of course, represents off, while one represents on.

Hexadecimal is more of an edge case. It’s used primarily as a convenient way to represent binary values for human operators. A single place value in hexadecimal represents four bits of memory. That means two places represents eight bits, or one byte. That’s why you’ll see hexadecimal used to represent the value of memory registers. The bit sizing makes it a natural fit, and it’s easier to read than a string of ones and zeros.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.