While numbering systems are not part of the hardware of a computer, understanding numbering systems is helpful for programming computers. This article provides some basic explanation of numbering systems and why the use of different numbering systems are helpful in understanding how computers work. A heads up, I like math and this article contains a lot of math stuff in it. If you aren't into math, feel free to skip to the section about the usefulness of numbering systems for computer programming and usage.

### The Numbering Systems that Work Best with Computers

I will admit that this topic is one that I'm fond of. Computers are built on storing numbers and manipulating them, so there is a need for efficient tools to work with the numbers. Numbering systems are important for computers because of how numbers are stored as binary numbers, numbers which consist of only 0 and 1.

The numbering system most people use every day is known as the base ten system. For the base ten system it consists of the single digits of 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. These digits are used to represent numbers we use for working with money, counting up items and other activities where it is convenient to count things. These digits are used in columns and when the last digit, 9, is reach in counting, the column to the left has 1 added to it.

When using a numbering system, it is common to write in subscript the number of digits used in counting. Since the base ten system is usually a default, the When a number is written, the base number is included a subscript with the number. With the base ten system, since it is the default numbering system, the 10 subscript is usually left out of the number. If it is included, the number would look this way: 2910. For clarity, I will use this convention for the rest of the article.

For example, for the number twenty nine, the twenty represents that all ten digits have been used twice. The nine is added and represents that nine digits have been used. For the number one hundred and thirty three, three digits have been used once, a set of tens is used three times and ten sets of tens have been used once. Or expressed as a math problem, 100 + 30 + 3, each standing for a set of tens that are added together as a number.

However, computers only have two digits, 0 or 1 for representing numbers. Computer numbers can be interpreted in a base ten system but there are times when it is easier to use a different numbering system to represent values. In this case, a base two system, with only two possible digits, would work. When a base two system is used, the numbers are written in bytes as follows:

- 0000 00012 = 110
- 0000 00102 = 210
- 0000 00112 = 310
- 0000 01002 = 410
- 0001 01002 = 2010

Each column represents a set of 1's added together. Since there are only two digits, it takes more space to write or print out numbers in the computer. The large set of numbers that are alternating between 0 and 1 can also be challenging to proofread when looking for mistakes in source code or raw data. Because of these issues, other numbering systems were used to represent computer information in shorter space.

However, the binary system, base 2 numbering, does not convert well into base 10. It can be done, but it turns out that using a numbering system based on a power of 2 works very well when converting binary numbers. The two numbering systems that are used are octal, base 8 and hexadecimal, base 16, numbering systems.

Octal numbers are represented by the digits 0, 1, 2, 3, 4, 5, 6, and 7. Numbers would be represented as follows

- 0018 = 110
- 0028 = 210
- 0038 = 310
- 0048 = 410
- 0248 = 2010

Hexadecimal numbers use the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F to represent sixteen digits for the system. The systems used the ten digits used in a base 10 system and uses the first six letters of the alphabet to represent the six numbers after 1010. Hexadecimal numbers would be written as:

- 0116 =110
- 0816 = 810
- 0A16 = 1010
- 1016 = 1610
- 1416 = 2010

By using different numbering systems to represent binary numbers, it is easier to read and write the information that is passed to the CPU. This system works for representing positive integer numbers but needs to be tweaked in order to display negative integers or real numbers, i.e. numbers with a decimal point.

For negative numbers, a bit at the end of the memory space, a byte, is usually reserved and if it is set the number is negative. An example of this follows:

- 0000 00012 = 0116 = 110
- 1000 00012 = 8116 = -110
- 0010 01002 = 2416 = 3610
- 1010 01002 = A416 = -3610

The negative sign is only used for the base ten representation, in the other cases, the full number is used. The computer checks for the last bit that is set and when the number is displayed in base ten, it is displayed with a negative sign and the value of that column is not added to the total number.

Representing fractions in a computer is more difficult. Fractions in a computer can be represented using only 0 and 1. Numbers with a fractional portion, real numbers, are stored in a floating point format using an exponential number to represent the fraction*. This format can be seen on calculators, when the number becomes larger than what can be displayed on the screen. The number is expressed as decimal and with an exponent. The exponent is the power of 10 that the decimal should be multiplied by. For example, my old calculator can only display a maximum of 10 digits. But if I multiply a 10 digit number or add another large number to it, there will be too many digits to display as an answer. So the answer is displayed as a decimal with a number at the end that is the power of ten to multiply by. Here are some examples that I entered into my calculator to see what would happen

I entered in the number 5,896,587,486, which has ten digits.

I multiplied it times 2 (2 x 5,896,587,486 = 11,792,174,972). The 11,792,174,972 is too large to display in ten digits, so my calculator could not display that result

Instead it displays 1.179217497 e10 which is 1.179217497 * 1010. 10 to the tenth power is 10,000,000,000 so the final result is 11,792,174,970, displayed in a compact form. Because there are not enough digits, some precision is lost and the 2 on the end is not displayed.

Floating point numbers in computers work the same way but instead of a power of 10 the decimal portion is multiplied by a power of 2. For numbers less than zero, the power is negative, which is like dividing the number. Since computer memory can only hold values of 0 or 1, this means that more space is used to store real numbers than would be required if ten digits were available for the numbers.

The Usefulness of Different Numbering Systems

As I talk about numbering systems in this section, I will use some short hand for the different number types, primarily hexadecimal. If a number is shown with a small x in front of it, that indicates it is a hexadecimal number. This is a shorthand used for this numbering system, which is easier to type instead of setting a subscript of 16 after the number. Here is an example of the same value expressed in different number systems, with formal and informal notation. These are all different methods of representing the number sixty five.

6510 = 65 = 4116 = x41 = 0x41 = 1018 = 0100 00012

Numbering systems are a method that people use to more easily read data that is stored in a computer. No matter what system is used to represent the data, that data will always be stored as a series of 0 and 1's in the computer. Knowing and understanding this is helpful when creating and debugging software. It is easier to spot a difference in hexadecimal numbers than it is a series of binary numbers. For example, it is easier to see that x35B6 is different from x31B6. It can take more time to spot the difference between 0011010110110110 and 0011000110110110, the binary representation for both numbers.

The ability to think of computer data in different ways can help in solving problems in programming languages. IN the end, the art of programming computers is dependent on transforming a set of 0 and 1 into a display that is human readable. For example, most people would not think of the letter 'A' as a number. People also don't think of a blank, ' ', as an important part of text. For a computer, both the letter A and a blank space are stored as binary numbers that are translated into text that people can read. Once this is realized, this information can help to explain why things are ordered in certain ways by the computer.

For example, here is a list of items with a number in front of each item

- A for Apple
- B for Banana
- C for cranberry
- D for dates
- E for Emu berry
- F for Figs
- G for Grapefruit
- H for Huckleberry
- I for Imbe Fruit
- J for Juniper Berry
- K for Kumquat

The list is in the order we would expect it in, with the numbers moving up as expected. However, the computer might interpret the list in this order instead.

- A for Apple
- J for Juniper Berry
- K for Kumquat

- B for Banana
- C for cranberry
- D for dates
- E for Emu berry
- F for Figs
- G for Grapefruit
- H for Huckleberry
- I for Imbe Fruit

The blank space in front of the numbers is viewed as part of the whole value and so all of the numbers that start with 1 are grouped together. If the list continued into the 20's, all of the items starting with 2 would be grouped together. The problem can be corrected as follows:

- 01. A for Apple
- 02. B for Banana
- 03. C for cranberry
- 04. D for dates
- 05. E for Emu berry
- 06. F for Figs
- 07. G for Grapefruit
- 08. H for Huckleberry
- 09. I for Imbe Fruit
- 10. J for Juniper Berry
- 11. K for Kumquat

In this instance, the character for '0' is placed in front of the single digits which forces the list to keep to the order that is expected by humans. If you have a Windows computer, you can observe this when you create folders. If the list continued to over 100, then two 0's would need to be placed in front of the single digits and a single 0 in front of the two digits numbers in order to keep the order. Fortunately, modern software usually takes this into account and the zero is not always needed. For example, when I typed this list into the word processor, I had to force it to not delete the 0 in front of the lists for my example. The list also ordered correctly, with single and double digit numbers, without any additional fixes from myself.

The other part of the use of numbering systems is viewing text as numbers and understanding that a letter is equivalent to a number for the computer. I still remember the moment years ago when I understood that text in a computer is really a number that is translated for our convenience. Or as I realized the following

A is equivalent to x41 is equivalent to 65 is equivalent to 0100 0001

For a computer, the letter A can be displayed as an A, stored in binary as 0100 0001 and it can be read as hexadecimal x41 or the decimal value 65, which is the ASCII value assigned to a capital letter A. All of these values are simply a different way of reading a value stored in the computer. Most of the time we read the letter A, at other times it may be helpful to read the number x41 so that we can add or subtract to that value and transform the data into something else.

Since all text is represented as numbers in the computer, it makes it simpler to sort items in the computer. This sorting can also lead to unexpected behavior, as shown above. It should also be understood that the numbers used in the previous examples do not have the value represented. A digital 1 is not the same as a text 1. The number 1 is stored with a value of hexadecimal x31 in the computer. The number 0 is stored as hexadecimal x30. A blank space is stored as the hexadecimal value x20 in the computer.

When you see these values, it becomes more obvious why things are ordered as they are. The numbers for the list above are represented below as hexadecimal, with the text values to the right of the hex values. The first set is shown without a starting character of a zero. The second example is with a 0 before the single digit numbers.

1st Example

- 31 2e (1.)
- 31 31 2e (11.)
- 31 32 2e (12.)
- 32 2e (2.)

2nd Example

- 30 31 2e (01.)
- 30 32 2e (02.)
- …
- 31 31 2e (11.)
- 31 32 2e (12.)

Understanding that text is numbers can be an important part of debugging software. If there is not enough error checking on text entered into software, that text can accidentally overwrite other parts of the memory of the computer. Since all text is a number underneath, the computer may evaluate the text as numbers when it is processing other data. This can be used as a method to introduce commands into the software and cause the software to malfunction. As an example on the web, there are forms that people can fill out. These forms transfer information to software that is used to find information. If the error checking is inadequate, a hacker can type information and add commands to the text that will perform operations. These operations can cause records to get deleted or hidden data, such as passwords, to get downloaded by the hacker.

While people focus on the text, computers do their best work when working with numerical data. A lot of data is based on real numbers with decimal points. The recording of amounts for shopping transactions is a good example. The computer needs to store amounts with two decimal points, perform calculations and redisplay the value.

Due to the limitations of the underlying binary system for computers, this can cause problems with the accuracy of the data. There are numbers that have repeating digits so they cannot be fully represented in a computer. In the decimal system, an example of this type of number is the fraction 1/3. When one is divided by 3, the result is the repeating decimal of .333333. Another example is 2/3, which results in .66666. The fraction 1/3 is usually shown as .333 on a computer, but the fraction may show up as .6667. The computer rounds up, which in most cases is not that important. However, multiply that error and adding or subtracting the value and it can end up with a larger error in large sets of numbers. When using a binary system there are more instances of repeating decimals which leads to this type of errors.

If these rounding errors are not accounted for they can lead to problems during calculations that involve large amounts of numbers. This knowledge has allowed programmers to subtract these round off errors during bank transactions and transfer them to another account. The loss of less than one cent is noticeable for one transaction but multiplied over millions of transactions can lead to large amounts of money.

The study of numbers and digital accuracy is a specialty that is an important part of ensuring the accuracy of the calculations by the CPU. While an important part of computing, software languages are used to implement algorithms to ensure accuracy. The next article is a high level review of common elements of programming languages and how those elements impact the operation and usage of computers.

*Pictures by J.T. Harpster. Selected prints can be purchased at our Redbubble shop*

Support us on our Patreon site.

- Log in to post comments