Binary & Hexadecimal Numbering Systems

Introduction

All computers today deal with numbers in a binary format, either on (1) or off (0). So, if you want to become more familiar with how a computer operates, it is wise to know a little bit about binary and hexadecimal numbers. Almost all of the numbers you see when pertaining to computers deal with bits or bytes (8 bits). Your connection speed when you hook up to the internet is in bits per second (56bps), divide that by eight and you get your througput in bytes per second, the sectors on a disk are seperated into 512 byte units, the ASCII characters are represented by 256 characters (1 byte), the ammount of memory is represented into bytes (4096 kilobytes = 4MB), the display depth is represented in bytes (256 colors is represented with 8 bits per pixel), etc. So you can see how important it is to get a basic understanding of what the relationship between binary and hexadecimal numbers. After you read this essay, hopefully you will get enough of an understanding that you will begin to piece together how and why a computer deciphers the information the way it does.

Position Valued Representation

Position valued representation (PVR) is a system to represent any value with a limited number of symbols. Take the decimal system for example, we can represent any value that we need with only 10 symbols (0....9). In order for us to accomplish this with the decimal system we follow a simple set of rules - the first position to the left of the decimal point is worth 1. After that each digit's position is worth 10 times the position to it's immediate right. Thus once we go through the symbols 0,1...9, we add another digit to the column to the left and start over with the symbols (8,9,10,11).

Examples:
100=1..............Any number to the 0th power is 1
101=10............Any number to the 1th power is that number
102=100..........10*10
103=1000........10*10*10
104=10000......10*10*10*10

With the PVR system there are a number of rules that one must follow, wether it is the decimal (base 10), hexadecimal (base 16) or any other base PVR system.

  • The number of digits needed for the system is equal to the base. (i.e. decimal (base 10) has 10 digits)
  • The value of the largest digit is one less than the base.
  • The first position to the left of the "base point" is worth 1. (i.e. the decimal point is the base point of the decimal system.)
  • Every other position is worth base times the position value to its immediate right.

All of this is elementary when used with the decimal (base 10) system, but once you use a different base number it may get a little confusing at first. Now, let's take a look at the binary system.

Binary Numbering (Base 2)

Because all computers work with bits, which can only be either on or off, the binary (base 2) system was developed. Even though the binary system follows all of the PVR rules, it is more difficult to understand because there are only 2 digits - 0 and 1. To get a better understanding of the binary system, try to imagine a car odometer that only uses 2 numbers 0 and 1. Instead of going all the way to nine before it flips the next wheel over, it flips the next wheel over after one.


0000 - mile 0
0001 - mile 1
0010 - mile 2
0011 - mile 3
0100 - mile 4

It may be seem pretty basic here, but it isn't when you try to represent larger numbers. Because it is not practical for us to use the binary system, we use the hexadecimal or base 16 system when we need to express binary values.

Hexadecimal Numbering (Base 16)

The hecadecimal system is based on 16 characters, 0 thru 9, then A thru F. Base 16 gets kind of confusing because we are so used to the base 10 system, we tend to cross the two when working with bigger numbers. The most common errors are to assume that the "tens" position is based on 10 instead of 16. Example: 1E is not 10 + 14 = 24, all numbers are based on 16, so it would be 16 + 14 = 30.

Below is a reference chart for all the hexadecimal symbols, along with the equivalent in binary and decimal.

Binary Hex Decimal Binary Hex Decimal
0000 0 0 1000 8 8
0001 1 1 1001 9 9
0010 2 2 1010 A 10
0011 3 3 1011 B 11
0100 4 4 1100 C 12
0101 5 5 1101 D 13
0110 6 6 1110 E 14
0111 7 7 1111 F 15

The interesting thing about hexadecimal and binary systems is that all possible values that are expressed in one system, can be exactly expressed in the other system. The reason for this is that 2 is the only prime factor of 16. This may not seem amazing yet, but let's see how you convert binary into Hexadecimal.

Converting from binary to/from hexadecimal

Most computer designs today arrange bits into groups of eight, which of course are called bytes. When these eight bits are grouped by four, the contents of a byte can be expressed as a two digit hexadecimal number. This is true because there are 256 different patterns that can be contained in a byte - 28 = 256 for binary or 162 = 256 for hexadecimal. So converting from binary to hexadecimal and vice versa becomes extremely simple. The only rule you need to remember to convert from hexadecimal to binary is that one hexadecimal digit always poduces four binary digits. Because of this rule, there is a one to one relationship between a hexadecimal digit and a grouping of four binary digits. When converting from a binary to hexadecimal, always to remember to start 'grouping' the binary digits from the left, and add any leading zeroes you may need if you don't have enoug digits. So, refering to the chart above, check out these examples:

Hexadecimal to Binary
516 = 01012
5A16 = 0101 10102
A516 = 1010 01012
A5116 = 1010 0101 00012
Binary to Hexadecimal
0100 00102 = 4216
1110 10012 = E916
0001 1100 00112 = 1C316

Note that a subscript (XY) represents what base a digit is representing.

Adding and Multiplying Hexadecimal Numbers

Currently, we are not going to go into how to add or multiply hexadecimal numbers here (use a calculator). We will however put up a couple more charts for you to reference in case you need it.


Hexadecimal Addition Table
+ 1 2 3 4 5 6 7 8 9 A B C D E F
1 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
2 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11
3 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12
4 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13
5 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14
6 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15
7 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16
8 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17
9 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18
A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19
B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A
C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B
D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C
E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D
F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E


Hexadecimal Multiplication Table
* 1 2 3 4 5 6 7 8 9 A B C D E F
1 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
2 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
3 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D
4 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
5 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B
6 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A
7 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69
8 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
9 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87
A 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96
B 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5
C 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4
D 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3
E 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2
F 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1

Google Ad

© 2017 Mike Petersen - All Rights Reserved