The Numeric Systems: Overview
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 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.
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:
Between 10 and 99, a number is represented by left-digit * 101 + right-digit * 100. For example:
In the same way:
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
67048 = 6*104 + 7*103 + 0*102 + 4*101 + 8*100
= 6*10000 + 7*1000 + 0*100 + 4*10 + 8*1
Another way you can represent this is by using the following table:
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.
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.
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?
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.
|Copyright © 2003-2008 FunctionX, Inc.||Next|