 The Numeric Systems: Overview

 Introduction

When using a computer application (or program), a person enters different types of values such as numbers, names, sentences. In some cases, a user selects values, drags the mouse, or performs some other type of operation. To manages these entries and actions, the computer partly uses numbers. This is information that you may need to know, especially if you are a programmer.

A value that a user enters into a control of an application is firstly stored in an area of the random access memory (RAM) and can be saved later on in a storage area such as a hard, floppy, CD, or flash drive. Different values (numbers, text, conditions) use different amounts of memory. How much space is necessary? How does the compiler figure out that space? This detail is taken care of by your supplying a piece of information called a data type. To determine the amount of space necessary, the computer deals with a numeric system.

There are three numeric systems that can be involved in a program, with or without the programmer's intervention. The decimal system provides the counting techniques that you use everyday but that the computer is not familiar with. The hexadecimal system is an intermediary system that can allow you to know how the computer deals with numbers. The binary system is the technique the computer uses to find out (almost) everything in your program.

 The Decimal  System

The numeric system uses a set of ten symbols that are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each of these symbols is called a digit. Using a combination of these digits, you can display numeric values of any kind, such as 240, 3826 or 234523. This system of representing numeric values is called the decimal system because it is based on 10 digits.

When a number starts with 0, a calculator or a computer ignores the 0. Consequently, 0248 is the same as 248; 030426 is the same as 30426. From now on, we will represent a numeric value in the decimal system without ever starting with 0: this will reduce, if not eliminate, any confusion. Decimal Values: 3849, 279, 917293, 39473 Non-Decimal Values: 0237, 0276382, k2783, R3273

The decimal system is said to use a base 10. This allows you to recognize and be able to read any number. Indeed, the system works in increments of 0, 10, 100, 1000, 10000, and up. In the decimal system:

• 0 is 0*100 = 0*1, which is 0
• 1 is 1*100 = 1*1, which is 1
• 2 is 2*100 = 2*1, which is 2
• And 9 is 9*100 = 9*1, which is 9

Between 10 and 99, a number is represented by left-digit * 101 + right-digit * 100. For example:

• 32 = 3*101 + 2*100 = 3*10 + 2*1 = 30 + 2 = 32

In the same way:

• 85 = 8*101 + 5*100 = 8*10 + 5*1 = 80 + 5 = 85

Using the same logic, you can get any number in the decimal system. Examples are:

2751  = 2*103 + 7*102 + 5*101 + 1*100

= 2*1000 + 7*100 + 5*10 + 1

= 2000 + 700 + 50 + 1

= 2751

67048 = 6*104 + 7*103 + 0*102 + 4*101 + 8*100

= 6*10000 + 7*1000 + 0*100 + 4*10 + 8*1

= 67048

Another way you can represent this is by using the following table:

 etc Add 0 to the preceding left value 1000000 100000 10000 1000 100 10 0

When these numbers get large, they become difficult to read; an example is 279174394327. To make this easier to read, you can refer to Digit Grouping Symbol used in your language to separate each thousand fraction with a comma. In US English, this symbol is the comma: Notice the character in the Digit Grouping Symbol combo box. Using it, we can write a large number as 279,174,394,327. Practical Learning: Introducing the Decimal System
1. Start the Calculator application (Start -> (All) Programs -> Accessories -> Calculator)
2. On the main menu, click View -> Scientific and, if necessary, click the Dec radio button 3. To see an example of a decimal number, using the buttons on the right side of the Calculator, type 2751
4. To erase the number, click CE
5. To display another number, using your keyboard, type 67048
6. To erase the number, click CE
 The Binary System

The system that the computer recognizes is made of only two symbols 0 and 1. The computer considers a piece of information to be true or to be false; and it assigns a value accordingly. Therefore, the binary system only counts 0 and 1. To get a number, you combine these values. Examples of binary numbers are 1, 100, 1011, or 1101111011.

When reading a binary number such as 1101, you should not pronounce "One Thousand One Hundred And 1", because such a reading is not accurate. Instead, you should pronounce 1 as One and 0 as zero or o. 1101 should be pronounced One One Zero One, or One One o One.

The sequence of the symbols of the binary system depends on the number that you are trying to represent. Practical Learning: Introducing the Binary System

1. To use the binary system, using the buttons on the Calculator, click 2 and click 6
2. Click the Bin radio button
3. Notice that the text box now displays a binary number made of 1s and 0s
4. Also notice that, on the right side of the window, only the 1 and 0 buttons are enabled while the others (2, 3, 4, 5, 6, 7, 8, and 9) have been disabled 5. To erase the number, click CE
6. To enter a binary number, click the 1 and 0 buttons to produce 1000110
7. To erase the number, click CE
8. Click the Dec radio button

Another technique of representing numbers uses sixteen (16) values: this is the hexadecimal system. Since the decimal system provides only 10 digits, the hexadecimal system adds some alphabetical characters. After counting from 0 to 9, the system adds letters until it gets 16 different values. The letters used are a, b, c, d, e, and f, or their uppercase equivalents A, B, C, D, E, and F. Therefore, the hexadecimal system counts as follows: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f; or 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

To produce a number, you use a combination of these sixteen symbols. Examples of hexadecimal numbers are 293, 0, df, a37, c23b34, or ffed54. At first glance, the decimal representation of 8024 and the hexadecimal representation of 8024 are the same. Also, when you see fed, is it a name of a federal agency or a hexadecimal number? Does CAB represent a taxi, a social organization, or a hexadecimal number? Therefore, from now on, to express the difference between a decimal number and a hexadecimal one, each hexadecimal number will start with 0x or 0X. The number will be followed by a valid hexadecimal combination. The letter can be in uppercase or lowercase. Legal Hexadecimals: 0x273, 0xfeaa, 0Xfe3, 0x35FD, 0x32F4e Non-Hex Numbers: 0686, ffekj, 87fe6y, 312 Practical Learning: Introducing the Hexadecimal System

1. To use the hexadecimal system, using the buttons on the Calculator, click 6, 7, 0, 4, and 8
2. Notice that, in the lower-right section of the window, the A, B, C, D, E, and F buttons are disabled
3. Click the Hex radio button
4. Now notice that, in the lower-right section of the window, the A, B, C, D, E, and F buttons have been enabled 5. To enter a different number, using your keyboard, type E88FD20 6. To show the number in decimal format, click the Dec radio button 7. To show the number in the binary system, click the Bin radio button 8. Click the Dec radio button
 Signed and Unsigned Numbers

You may have noticed that the numbers we have used so far were counting from 0, then 1, then 2, and up to any number desired, in incrementing values. Such a number that increments from 0, 1, 2, and up is qualified as positive. By convention, you do not need to let the computer or someone else know that such a number is positive: by just displaying or saying it, the number is considered positive. There are also numbers counted in decrement values. Such numbers start at -1 and move down to -2, -3, -4 etc. These numbers are qualified as negative.

When you write a number "normally", the number is positive. If you want to express the number as negative, you use the - on the left side of the number. The - symbol is called a sign. Therefore, if the number does not have the - symbol, it is referred to as unsigned. If you want, you can precede the number with - to indicate that it is negative, or you can precede it with + to indicate that the number is positive. If you precede the number with one of these symbols, the number is referred to as signed.