The Decimal System
|
The numeric system that we have always used 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 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. 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:
When these numbers get large, they become difficult to read; an example
is 279174394327. To make this easier to read, you can separate each
thousand fraction with a comma. Our number would become 279,174,394,327.
You can do this only on paper, never in a program: the compiler would
not understand the
comma(s).
Why use the decimal system? Because, to represent numbers, that is the system that you and I are familiar with. |
The Hexadecimal System
|
While the decimal system uses 10 digits (they are all numeric), the
hexadecimal system uses sixteen (16) symbols to represent a number.
Since the Latin language consists of only 10 digits, we cannot make up
new ones. To compensate for this, the hexadecimal system uses alphabetic
characters. After counting from 0 to 9, the system uses 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. 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, and F. Once
again, 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? From now on, to express the difference between a decimal number and a hexadecimal one, each hexadecimal number will start with a $ symbol. The number will be followed by a valid hexadecimal combination. Legal Hexadecimals:$273, $feaa, $fe3, $35FD, $32F4eNon-Hex Numbers: 0686, ffekj, 87fe6y, 312 Why learn or use the hexadecimal system? Because the computer does not understand the decimal system, which is our everyday base of counting items, and because we do not understand or are not familiar with the binary system, the hexadecimal system provides an intermediary system. Also, the hexadecimal system use shorter forms of representing the same numbers in the decimal system. |
Signed and unsigned
|
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.
In real life, there are 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”, such as 42, 502, or 1250, that is, if there is no sign on the left side of the number, it is positive. Such a number, because it displays no sign, is referred to as unsigned. If you want to express the number as negative, you use the – sign on the left side of the number. When displaying such a sign, the number is referred to as signed. Therefore, if the number does not have the – sign, the compiler considers such a number as unsigned and it is positive. On the other hand, a number qualifies as signed when it can be positive or negative, depending on how it is used.
In real life, there are 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”, such as 42, 502, or 1250, that is, if there is no sign on the left side of the number, it is positive. Such a number, because it displays no sign, is referred to as unsigned. If you want to express the number as negative, you use the – sign on the left side of the number. When displaying such a sign, the number is referred to as signed. Therefore, if the number does not have the – sign, the compiler considers such a number as unsigned and it is positive. On the other hand, a number qualifies as signed when it can be positive or negative, depending on how it is used.
No comments:
Post a Comment