D ECIMAL N UMBER S YSTEM

D ECIMAL N UMBER S YSTEM

The decimal number system, which is the most common to us, was undoubtedly developed because humans have ten fingers and ten toes. Thus, the base of the decimal number system is 10. The symbols, or digits, used in this system are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. As noted earlier, the total number of symbols (10) is the same as the base, with the largest-valued symbol being

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION ntroductory Number Systems C HAPTER 1 Concepts

and Codes 2

one less than the base (9 is one less than 10). Because the decimal system is so common, we rarely stop to think about how to express a number greater than 9, the largest-valued symbol. It is, however, important to note that the technique for representing a value greater than the largest symbol is the same for any number system.

In the decimal system, a place value, or weight, is assigned to each position that a number greater than 9 would hold, starting from right to left. The first position (see Figure 2-1), starting from the right-most position, is position 0, the second is position 1, and so on, up to the last position n. As shown in Figure 2-2, the weighted value of each position can be expressed as the base (10 in this case) raised to the power of n (the position). For the decimal system, then, the position weights from right to left are 1, 10, 100, 1000, etc. This method for computing the value of a number is known as the sum-of-the- weights method .

V n ...V 3 V 2 V 1 V 0

Figure 2-1. Place values.

Position ( n) 3 2 1 0

Value ( Position 3 V 2 V V) V 1 V Weight Value = 0 Base (Base = 10 for decimal)

Figure 2-2. Weighted values.

The value of a decimal number is computed by multiplying each digit by the weighted value of its position and then summing the results. Let’s take, for example, the number 9876. It can be expressed through the sum-of-the- weights method as:

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION Introductory Number Systems C HAPTER 1 Concepts

and Codes 2

As you will see in other number systems, the decimal equivalent of any number can be computed by multiplying each digit by its base raised to the power of the digit’s position. This is shown below:

Position

Number Z n

Z 3 Z 2 Z 1 Z 0 Base = b

Therefore, the sum of N 0 through N n will be the decimal equivalent of the

number in base b.

B I N A RY N UMBER S YSTEM

The binary number system uses the number 2 as the base. Thus, the only allowable digits are 0 and 1; there are no 2s, 3s, etc. For devices such as programmable controllers and digital computers, the binary system is the most useful. It was adopted for convenience, since it is easier to design machines that distinguish between only two entities, or numbers (i.e., 0 and 1), rather than ten, as in decimal. Most physical elements have only two states: a light bulb is on or off, a valve is open or closed, a switch is on or off, and so on. In fact, you see this number system every time you use a computer—if you want to turn it on, you flip the switch to the 1 position; if you want to turn it off, you flip the switch to the 0 position (see Figure 2-3). Digital circuits can distinguish between two voltage levels (e.g., +5 V and 0 V), which makes the binary system very useful for digital applications.

Figure 2-3. The binary numbers, 1 and 0, on a computer’s power switch represent ON and

OFF, respectively.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION ntroductory Number Systems C HAPTER 1 Concepts

and Codes 2

As with the decimal system, expressing binary numbers greater than the largest-valued symbol (in this case 1) is accomplished by assigning a weighted value to each position from right to left. The weighted value (decimal equivalent) of a binary number is computed the same way as it is for

a decimal number—only instead of being 10 raised to the power of the position, it is 2 raised to the power of the position. For binary, then, the weighted values from right to left are 1, 2, 4, 8, 16, 32, 64, etc., representing positions 0, 1, 2, 3, 4, 5, 6, etc. Let’s calculate the decimal value that is equivalent to the value of the binary number 10110110:

Thus, the binary number 10110110 is equivalent to the number 182 in the decimal system. Each digit of a binary number is known as a bit; hence, this particular binary number, 10110110 (182 decimal), has 8 bits. A group of 4 bits is known as a nibble; a group of 8 bits is a byte; and a group of one or more bytes is a word. Figure 2-4 presents a binary number composed of 16 bits, with the least significant bit (LSB), the lowest valued bit in the word, and the most significant bit (MSB) , the largest valued bit in the word, identified.

Most

Least

Significant Bit

Significant Bit

Figure 2-4. One word, two bytes, sixteen bits.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION Introductory Number Systems C HAPTER 1 Concepts

and Codes 2

Counting in binary is a little more awkward than counting in decimal for the simple reason that we are not used to it. Because the binary number system uses only two digits, we can only count from 0 to 1—only one change in one digit location (OFF to ON) before a new digit position must be added. Conversely, in the decimal system, we can count from 0 to 9, equaling ten digit transitions, before a new digit position is added.

In binary, just like in decimal, we add another digit position once we run out of transitions. So, when we count in binary, the digit following 0 and 1 is 10 (one-zero, not ten), just like when we count 0, 1, 2…9 in decimal, another digit position is added and the next digit is 10 (ten). Table 2-1 shows a count in

binary from 0 10 to 15 10 .

Table 2-1. Decimal and binary counting.