Sie sind auf Seite 1von 30

UNIT-I

LESSON

1
NUMBER SYSTEMS
CONTENTS
1.0 Aims and Objectives 1.1 Introduction 1.2 Different Number Systems 1.2.1 Decimal Number System 1.2.2 Binary Number System 1.3 Conversions 1.3.1 Decimal to Other Number Systems 1.3.2 Binary System to Other Number Systems 1.3.3 Octal Number System to Other Number Systems 1.3.4 Hexadecimal System to Other Systems 1.4 Complements 1.5 Arithmetic Operation in Binary Number System 1.5.1 Addition 1.5.2 Subtraction 1.5.3 Multiplication 1.5.4 Division 1.6 Floating Point Representation of Numbers 1.6.1 Fixed Point Format 1.6.2 Floating Point Format 1.7 Binary Codes 1.7.1 BCD (Binary Coded Decimal) 1.7.2 EBCDIC (Extended Binary Coded Decimal Interchange Code) 1.7.3 Excess-3 Code 1.7.4 Gray Code 1.8 Let us Sum up 1.9 Lesson end Activities 1.10 Keywords 1.11 Questions for Discussion 1.12 Suggested Readings

Computer Organization and Architecture

1.0 AIMS AND OBJECTIVES


After completion of this unit, you should be able to: (i) (ii) Describe different number systems Describe Binary, decimal, Octal and Hexadecimal number system

(iii) Convert one form of number to another form (iv) Calculate complements of binary numbers (v) Describe binary codes

1.1 INTRODUCTION
Computers being electronic machines, characters and numbers have to be represented in the form of electronic pulses. If the computer has to work with the decimal number system, computer circuitry should be designed such that it should be able to generate and identify ten different levels of electronic pulses (for ten digits 0-9). This will make the machine very complex and error-prone. The basic elements in early computers were relay switches. The operations of a switch or relay can be seen to be essentially binary in nature. That is a switch is either on (1) or off (0). The modern computer system is based on the principle of transistors. For the purpose of reliability these devices are always in one or two states; set (1) or not set (0). However, to work with the binary number system, which deals with only two numbers, viz., 0 and 1, the computer circuit has to be designed such that it is able to generate and identify only two different levels of pulses. Each of these binary digits (0 and 1) is known as bit. A combination of these bits together constitutes a byte (8 bits = 1 byte). You will be learning about different number systems. The number system can be classified into two types:
l l

Non-positional Number System Positional Number System

Non-Positional Number System In ancient times people used stones and pebbles to count things. This method of counting uses an additive approach and is called the Non-Positional Number System. Due to the complexities of scientific calculations, this system was not able to work; hence, Positional Number System was developed. Positional Number System The positional number system contains a few digits only, just like Decimal Number system contains 10 digits (0, 1, 2,............., 8, 9) and binary number system contains two digits (0 and 1) only. The value of a particular number in a number system is calculated on the following basis: 1. 2. 3. The digit itself. The base of the number system (Like base of Decimal Number System is 10, and that of Binary Number System is 2). The position of digit in the number.

The most common number system that we make use of in our daily life is Decimal Number System whose base is 10 and it contains (0, 1, 2, 3,8, 9) digits.
8

Other popular number system that a computer uses is Binary Number System whose base is 2 and it contains only two digits 0 and 1.

Number Systems

1.2 DIFFERENT NUMBER SYSTEMS


A number system of base (also called radix) is a system which have r distinct symbols for r digits. A number is represented by a string of these symbolic digits. To determine the quantity that the number represents, we multiply the number by an integar power of r depending on the place it is located and then find the sum of weighted digits.

1.2.1 Decimal Number system


Our present number system with a base or radix of 10 is based on the use of ten different digits (0-9), known as Arabic numerals. The highest numerical symbol, i.e. 9 has a value one less than the base for the decimal number system. This number system is most easily understandable and is most popular in day-to-day life. Since the base or radix of this system is 10, a string of numbers 234.5 can be represented in quantity as: 2 102 + 3 101 + 4 100 + 2 10-1

1.2.2 Binary Number System


Gotfried wilhelm Von Leibnitz advocated the use of binary number system in the 17th century. Binary number system uses only two digits, i.e. 0 and 1 and has a base of 2. All decimal numbers can be represented using the combination of these two digits only. Use of binary number system in computers simplifies the design, reduces the cost and improves the reliability of the computer. It also simplifies the design of storage devices. All the modern computers use binary number (0 and 1) system. The binary number system is the most natural number system, requires a small amount of circuitry and is more efficient. Octal Number System A number system with base or radix of 8 is known as octal number system. Digits used in this number system are 0 to 7. For the representation of octal number in binary number systems, 3 bits are required to represent each digit of octal numbers system. Hexadecimal Number System Hexadecimal is a number system with base of 16. Digits used in this number system are 0 to 9 and A, B, C, D, E, F where decimal values of A to F are 10 to 15 respectively. A represents 10, B represents 11 and so on. In binary representation, 4 bits (1 nibble) are used to represent each digit of hexadecimal numbers. It is more compact than any other number system.
Check Your Progress 1

1.

What are positional and non-positional number systems? ............................................................................................................. ............................................................................................................. ............................................................................................................. .............................................................................................................

Contd....

Computer Organization and Architecture

2.

Describe the following: (i) (ii) Decimal Number System Binary Number System

(iii) Octal Number System (iv) Hexadecimal Number System ............................................................................................................. ............................................................................................................. ............................................................................................................. .............................................................................................................

1.3 CONVERSIONS
All the number systems discussed above can be inter- converted to one other. The set of rules to convert them are discussed below:

1.3.1 Decimal to Other Number Systems


The decimal number systems can be converted to other number systems by using either of the two methods given below: Power Method a. b. c. d. e. f. Writing the powers of the radix till it is less than the number to be converted. Subtracting the highest number, which is obtained by raising the powers of the radix from the number, which is to be converted. Obtaining the remainder say R. Subtracting the next highest number from this remainder. Repeating the process till the remainder is zero. Now multiplying the powers, which have been used with one and multiplying the powers by zero which have not been used.

Remainder Method This is the method commonly used for the conversions from decimal number system to the binary number system. The conversion is carried out in the following order: divide the given number (decimal system) by the radix of the proposed system (in which the number has to be converted). Note down the remainder. Now the quotient will again be divided by the radix and the remainder will be noted down. The procedure goes on till zero comes as quotient.

10

Fractions We have already discussed the remainder and the power methods to convert the decimal numbers to binary numbers. Now the fractional decimal numbers can be converted to binary numbers by following the steps given below: 1. 2. 3. 4. Multiply the radix of the proposed system with the fraction to be converted. Note down the resulting integer (if any) otherwise put down zero in that place. Repeat the multiplication with the resulting fraction. Keep repeating the procedure till the fraction vanishes or you encounter the recursive fractions.

Number Systems

Decimal to Binary Conversion Examples: 1. By using Power Method: i. (220)10 Radix of the binary system = 2 Powers of radix which are less than 220 21 22 23 24 25 26 27 220 - 128 92 - 64 28 - 16 12 - 8 4 4 22=122 23=123 2 4= 1 2 4 26=126 27=127 2 4 8 16 32 64 128

0
127 126 025 124 1 1 0 1
11

Computer Organization and Architecture

123 122 021 020

1 1 0 0

Thus binary equivalent of 22010 is (11011100)2 ii. (674)10 Radix of the binary system = 2 Powers of radix which are less than 674 2 2 2 2 2 2 2 2 2
1 2 3 4 5 6 7 8 9

2 4 8 16 32 64 128 256 51

674 - 512 162 - 128 34 - 32 2 2 0 1 29 0 25 12


7

29=129

2 7 = 1 27

25 = 1 2 5

2 1 = 1 21

1 0 1 0 1 0 0 0 1 0

0 25 1 25 0 24 0 23 02
2

1 21 0 20

Thus binary equivalent of 67410 is (1010100010)2


12

2.

By using Remainder method i. 22010 2 2 2 2 2 2 2 2 0 220 110 55 27 13 6 3 1 1 0 0 1 1 1 0 1

Number Systems

While writing the binary equivalent the digits are taken from bottom to top (as indicated by arrow). The binary equivalent in the above example is (11011100)2 ii. 67410 2 2 2 2 2 2 2 2 2 2 0 674 337 168 84 42 21 10 5 2 1 1 0 1 0 0 0 1 0 1 0

Thus binary equivalent of 67410 is (1010100010)2 Fractions Converting (0.40) to binary form Radix = 2 Fraction 0.40 2 0.80 2 0.60 2 0.20 2 0.40 2 = 0.80 = 1.60 = 1.20 = 0.40 = 0.80 Integer 0 1 1 0 0

thus binary equivalent of 0.4010= (0.01100)2 (12.25)10 Radix =2


13

Computer Organization and Architecture

Integer part = 12. Using remainder method: 2 2 2 2 0 12 6 3 1 1 0 0 1

Thus binary equivalent of 12 is (1100)2 Fraction part = 0.25 Fraction 0.25 2 0.50 2 = 0.50 = 1.00 Integer 0 1

The binary equivalent of (0.25)10 is (01)2 Thus the binary equivalent of (12.25)10 is (1100.10)2 Decimal to Octal 1. Integer
l

(98)10 Radix = 8 8 8 8 0 98 12 1 1 2 4

Thus octal equivalent of (98)10 is (142)8 2. Fraction


l

(423.03125)10 Integer Part = 423 8 8 8 8 0 423 52 8 1 1 7 4 0

Thus the octal equivalent of 423 is (1047)8 Fraction Part = 0.03125 Fraction 0.03125 8 0.250 8 = 0.250 = 2.00 Integer 0 2

That is (0.03125)10 = (0.02)8


14

Thus the octal equivalent of (423.03125)10 = (1047.02)8

Decimal to Hexadecimal Integer (8234)10 16 16 16 16 0 8234 514 32 2 2 10 2 0 10 = A

Number Systems

Thus the hexadecimal equivalent of (8234)10 is (202A) 16 Fraction (0.225)10 Fraction 0.225 16 0.6 16 = 3.6 =9.6 0.6 0.6 Integer 3 9

Thus the hexadecimal equivalent of (0.225)10 is (39)16

1.3.2 Binary System to Other Number Systems


Binary to Decimal Number System Binary number can be converted to decimal number system by multiplying each binary digit with its respective position weight and then adding all the results. Examples: 1. (10100011)2 1 0 1 0 0 0 1 1 27 26 25 24 23 22 21 20 = = = = = = = = 128 0 32 0 0 0 2 1 163

2.

(1101)2 1 1 0 1 23 22 21 20 = = = = 8 4 0 1 13
15

Computer Organization and Architecture

Binary to Decimal (Fraction) The binary fractions are converted to the decimal number systems by multiplying each digit by their respective position weights (that is the negative powers of the base 2) and then adding them together. Example: (1011.11011)2 Consider the inter part first 1 0 1 1 23 22 21 20 = = = = 8 0 2 1 11 Consider the fraction part now: Fraction = (0.11011)2 = = = 1 2 1 + 1 22 + 0 2 3 + 1 2 4 1 2 + + 0 + 1/16 + 1/32
-5

(0.84375)10

Thus the decimal equivalent of (1011.11011) 2 is (11.84375) 10 Binary to Octal Number System Binary numbers can be converted to octal number system by two methods: 1. 2. By converting the binary number first into the decimal number system and then converting the number so obtained into octal number system. By grouping three binary digits to produce a single octal number proceeding from least significant bit to most significant bit.

Examples: 1. Integer (110100101)2 First converting the above binary number to the decimal equivalent by multiplying each digit with its respective position weight : 1 1 2
8

0 2
7

1 2 0
6

0 2
5

0 2 0
4

1 2 0
3

0 2 4
2

1 21 0 1 20

256

128

32

= 256 + 128 + 0 + 32 + 0 + 0 + 4 + 0 + 1 = 421 Now converting this decimal to equivalent octal form: 8 8 8 0
16

421 52 6 6 5 4

Thus the octal equivalent of (421)10 is (645)8

(110100101)2 = (421)10 = (645)8 Converting the same number by the second method that is by grouping the binary number.
Binary Number (grouped in 3 bits) In equivalent exponential form In decimal form In octal from 645 110 222120 4 2 1 100 222120 4 2 1 101 222120 4 2 1

Number Systems

4x1+2x1+1x0

4x1+2x0+1x0

4x1+1x0+1x1

Therefore the octal equivalent of (110100101)2 is (645)8 2. Fraction Example: (110111001.100001)2 Let us first convert the above given binary number to the decimal equivalent: Integer part: (110111001) 2 = = = 1 x 28 + 1 x 2 7 + 0 x 2 6 + 1 x 2 5 + 1 x 2 4 + 1 x 2 3 + 0 x 22 + 0 x 21 + 1 x 20 256 + 128 + 0 + 32 + 16 + 8 + 0 + 0 + 1 (442)10 442 55 7 7 2 7

Now converting this decimal form into octal form: 8 8 8 0

Thus octal equivalent of integer part 442 is (772)8 Fractional part: (0.100001)2 = + 1/ 64 = 33/64 = (0.515625)10 Now converting this decimal form into octal form: Fraction = 0.515625 Fraction 0.515625 0.125 8 8 = = 4.125 1.000 Integer 4 1

Thus the octal equivalent of (0.515625)10 = (0.41)8 Therefore (110111001.100001)2 =(442.515625)10 = (772.41)8 Binary to Hexadecimal Integer For converting a binary number into its hexadecimal equivalent, it should be first converted into groups of four bits and then these groups can directly be converted into their hexadecimal equivalents.

17

Computer Organization and Architecture

Example: (1110100010111100)2
1110 1x8+1x4+1x2+0 x 1 13=D 1000 1x8+0x4+0x2+0x1 8=8 1011 1x8+0x4+1x2+1x1 11=B 1100 1x8+1x4+0x2+0x1 12=C

Thus the hexadecimal equivalent of (1110100010111100)2 is (D8BC) 16 Fraction Even the fraction part is converted into a group of four bits and then converted to corresponding hexadecimal number. The grouping starts from the very next bit after the decimal and proceeds towards the right. Example: (0.11001101)2 1100 12 = C 1101 13 = D

Therefore the hexadecimal equivalent of (0.11001101)2 = (CD)16

1.3.3 Octal Number System to Other Number Systems


Octal to Decimal Integer For converting the octal number to its decimal equivalent, each digit is multiplied with its respective position weight and then added to get the desired octal number. Example: (349) 3 8 2 = 64 192 = 192 + 32 + 9 = (233)8 Fraction For converting the fractional octal number to its decimal equivalent, each digit is multiplied with its respective position weights (i.e. the negative powers of the radix 8) and then added together to get the result. Example: (0.265)8 = 2 x 8 1 + 6 x 8 2 + 5 x 8 3 = 2/8 + 6/ 64 + 5/ 512 = (0.353515625) 10 Therefore (0.265)8 = (0.353515625)
18
10 8

4 81=8 32

9 8 0= 1 9

Octal to Binary For converting the octal number to binary number, it has to be first converted into decimal form and then to binary. Example (243)8 Converting the above given octal number to decimal form first: (243)8 =282+481+380 = 2 64 + 4 8 + 3 1 = 128 + 32 + 3 = (163)10 Now converting this decimal equivalent to the binary form: 2 2 2 2 2 2 2 2 163 81 40 20 10 5 2 1 0 1 1 0 0 0 1 0 1

Number Systems

Thus the binary equivalent of (163)10 = (10100011)2 Therefore (265)8 = (163)10 = (10100011)2 Fraction For converting the octal number to its binary equivalent, it has to be converted first into its decimal form. Example: (0.25)8 (0.25)8 = 2 x 81 + 5 x 82 = 2/8 + 5/64 = 21/64 = (0.328125)10 Now converting this decimal number to its binary equivalent: Fraction 0.328125 2 = 1.3125 0.3125 0.25 0.50 2 = 1.25 2 = 0.50 2 = 1.00 0.3125 0.25 0.50 0.00 Integer 1 1 0 1

Thus the binary equivalent of (0.328125)10 is (0.1101)2 Therefore (0.25)8 = (0.328125)10 = (0.1101)2
19

Computer Organization and Architecture

1.3.4 Hexadecimal System to Other Systems


Hexadecimal to Decimal Each digit of the hexadecimal number is multiplied with its respective position weight and then added to get the number in the proposed system. Example: (E28B)16 E = 14 163 = 4096 14 x 4096 57344 2 162 = 256 2 x 256 512 8 161 = 16 8 x 16 128 B = 11 160 = 1 11 x 1 11

= 57344 + 512 + 128 + 11 = (57995)10 Therefore (E28B)16 = (57995)10 Hexadecimal to Binary 1st Method A hexadecimal number can be converted to its binary equivalent by first converting it to the equivalent decimal number and then converting the resultant decimal number to the binary number. Example: (C3B1)16 Converting (C3B1)16 to its equivalent decimal form: 1 x B x 3 x C x 16 0 16 1 16 2 16 3 = = = 16 176 768

= 49152 50112

Thus (C3B1)16 =

(50112)10

Now converting this decimal from to its equivalent binary form:

2 2 2 2 2 2 2 2 2 2 2
20

50112 25056 12528 6264 3132 1566 783 391 195 97 48

0 0 0 0 0 0 1 1 1 1
Contd....

2 2 2 2 2

24 12 6 3 1

0 0 0 0 1

Number Systems

Thus the binary equivalent of (50112 )10 is (1100001111000000)2 Therefore (C3B1)16 = (50112)10 = (1100001111000000)2 2nd Method A hexadecimal number is first converted into its decimal equivalent and then the decimal number so obtained is converted to the group of binary digits. It uses the group of four bits to represent a single number
Hexadecimal Decimal Binary Position Binary Number C 12 23222120 8 1100 4 2 1 3 3 23222120 8 4 2 1 B 11 23222120 8 4 2 1 1 1 23222120 8 4 2 1

0011

1011

0001

1.4 COMPLEMENTS
There are two types of complements for a number of base r, these are called rs complement and (r-1)s complement. For example, for decimal numbers the base is 10, therefore, complements will be 10s complement and (101) = 9s complement. For binary numbers we talk about 2s and is complement. But how to obtain these complements and what does these complements mean? Let us discuss these issues with the help of following examples. Example: Find the 9s complement and 10s complement for the decimal number 256. Solution 9s complement: The 9s complement is obtained by subtracting each digit of the number from 9 (the highest digit value). Similarly, for obtaining is complement for a binary number we have to subtract each binary digit of that number from the digit 1 in the same manner given in the example.
9 9 9 -6 3 -2 - 5 7 4

9s complement of 256

10s Complement: The 10s complement is obtained by adding 1 in the 9s complement. 10s complement of 256 = 743 + 1 = 744 Please not on adding the number and its 9s complement we get 999 (for this three digit number) and on adding the number an its complement, we get 1000. Example: Find 1s and 2s complement 1010. Solution: 1s complement of 1010 is:
1 = 1 1 1
21

-1 - 0 - 1 - 0 0 1 0 1

Computer Organization and Architecture

Please note that where we have 1 in number the complement contains 0 for that digit and vice versa. In other words to obtain is complement of a binary number, we only have to change all the 1s of the number to 0 and all the zeros to 1s. This can be alone by complementing each bit. 2s Complement: The 2s complement can be obtained by adding 1 in 1s complement. 2s complement =

0 1 0 1 +1 0 1 1 0
Most Significant bit Least Significant bit

The number is 2s complement is

1 0 1 0 0 1 1 0 No Change in these bits

The 2s complement can also be obtained by not complementing all the least significant zeros till the first 1 is encountered. This 1 is also not complemented. After this 1 rest all the bits are complemented. Therefore, 2s complement of the following (using this method) will be (you can check it by finding 2s complement as we have done in the example. Number 100100 100000 2s complement 0 11100 No change in these bits 100000 No Change in number and its complement, a special case. 101001 01011 No change in this bit.

1.5 ARITHMETIC OPERATION IN BINARY NUMBER SYSTEM


All the arithmetic operations (addition, subtraction, multiplication and division) in binary system are performed in the same way as in decimal number system. All the four arithmetic operations are described as below:

1.5.1 Addition
Rules for carrying out binary additions are: 0+0=0 0+1=1 1+0=1 1 + 1 = 0 with one (1) carry over. Examples: 1. For adding 1011102 and 1111012 Binary 101110 111101 1101011
22

Decimal 46 61 107

Thus 1101011 in binary system is equivalent to 107 in decimal system.

2.

For adding 100000 and 1011 Binary 100000 1011 101011 Decimal 32 11 43

Number Systems

the binary equivalent to 43 in decimal system is 101011 in binary system.

1.5.2 Subtraction
Rules for carrying out binary subtractions are: 1. 2. 3. 4. 1. 00=0 0 1 = 1 with one borrow 10=1 11=0 For subtracting 1011102 from 1111012 Binary 111101 101110 001111 2. Decimal 61 46 15

Examples:

Thus 001111 in binary system is equivalent to 15 in decimal system. For subtracting 1011 from 100000 Binary 100000 1011 10101 Decimal 32 11 21

The binary equivalent to 43 in decimal system is 101011 in binary system.

1.5.3 Multiplication
The rules for the multiplication are: 00=0 01=0 11=1 Examples are Multiplying 111101 with 1110 Binary 111101 1110 000000 111101x 111101xx 111101xxx 1101010110
23

Decimal 61 14 244 61x 854

Computer Organization and Architecture

Multiply 110 with 010 Binary 110 x 010 000 110x 000xx 01100

1.5.4 Division
The rules for division are same in binary system as those in decimal number system. 110 100100 110 0110 110 X This is same as division of decimal 36 with 6. 0110

1.6 FLOATING POINT REPRESENTATION OF NUMBERS


Fraction numbers can be represented in two different ways fixed point format and floating point format both having their own sets of advantages and disadvantages.

1.6.1 Fixed Point Format


In this representation the position of the decimal point remains fixed at the given place. In order to perform arithmetic on such numbers the decimal point must be aligned to all the addenda. Thus, to compute 3436.093 + 23.78457 + 0.87 + 2652363.19, we need to align the decimal points as shown below. 0003436.09300 0000023.78457 0000000.87000 2652363.19000 This representation wastes a lot of space and requires lot of adjustments, hence is unsuitable for many purposes.

1.6.2 Floating Point Format


This representation overcomes the limitations of the fixed point format representation. It is more space efficient as well as easier for computation. In this representation the fraction number is broken into two pieces mantissa and exponent. The number standardized to be between 1 to 10 (in decimal) is the mantissa while exponent is the radix with which the mantissa must be multiplied to get the actual number. For example, Mantissa of 746.002D is 7.46002D while the exponent is 2 because 746.002D = 7.46002D x 102 In the binary form the base remains 2 instead of 10. Thus the binary fraction 111.0010101B can be written in the floating point notation as,
24

1.110010101 22

1.7 BINARY CODES


1.7.1 BCD (Binary Coded Decimal)
Decimal digit 0 1 2 3 4 5 6 7 8 9 BCD Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Number Systems

Note that values 1010, 1011, 1100, 1101, 1110 and 1111 do not represent any value in BCD. Example: Represent 475D in binary and BCD. Solution: Binary representation of 475D BCD representation of 475D = 111011011B = 0100 0111 0101BCD

Since, in most of the computers the minimum storage is a byte, a lot of memory is wasted in BCD. In order to use the memory more efficiently Packed BCD has been developed. In Packed Binary Decimal Coding scheme, two BCDs are packed in one byte.

1.7.2 EBCDIC (Extended Binary Coded Decimal Interchange Code)


This coding scheme was developed by IBM as an extension to the Binary Coded Decimal (BCD) format. EBCDIC extends BCD from 4 bits to 8 bits. This way it encodes not only 10 decimal digits, but also the upper and the lower case letters, formatting codes like headers and carriage returns, and basic communication controls like Request, Acknowledge, and Beep. The first four bits in the EBCDIC byte define the class of character and the second specifies the actual character in that class. If all the first four bits are 1 then the specified character shall be assumed to be number. Continuing with same spirit EBCDIC was further extended to 16 and 32 bit variants to allow for representation of large, non-latin character sets. These variants are known as codepage. This has enabled representation of complex languages like Chinese, Korean and Japanese, that have large number of characters in their alphabets. Here is the EBCDIC table of character representation.
Dec 0 1 2 3 4 5 6 7 8 9 10 DEL HT Code NUL SOH STX ETX Dec 32 33 34 35 36 37 38 39 40 41 42 LF ETB ESC Code Dec 64 65 66 67 68 69 70 71 72 73 74 [ Code space Dec 96 97 98 99 100 101 102 103 104 105 106 | Contd....
25

Code /

Computer Organization and Architecture

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

VT FF CR SO SI DLE

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 ENQ ACK BEL

75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223

. < ( + |! &

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

, % _ > ?

SYN

BS CAN EM

EOT

IFS IGS IRS IUS a b c d e f g h i

!] $ * ) ; ^ { A B C D E F G H I

: # @ = \ S T U V W X Y Z

NAK SUB ~ s t u v w x y z

j k l m n o p q r

} J K L M N O P Q R

0 1 2 3 4 5 6 7 8 9

26

ASCII (American Standard Code for Information Interchange) This is a 7-bit coding scheme very similar to EBCDIC. The coding scheme is given in the following table.
Decimal 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 Octal 000 001 002 003 004 005 006 007 010 011 012 013 014 015 016 017 020 021 022 023 024 025 026 027 030 031 032 033 034 035 036 037 040 041 042 043 044 045 046 047 050 051 052 053 Hex 000 001 002 003 004 005 006 007 008 009 00A 00B 00C 00D 00E 00F 010 011 012 013 014 015 016 017 018 019 01A 01B 01C 01D 01E 01F 020 021 022 023 024 025 026 027 028 029 02A 02B Binary 00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010 00001011 00001100 00001101 00001110 00001111 00010000 00010001 00010010 00010011 00010100 00010101 00010110 00010111 00011000 00011001 00011010 00011011 00011100 00011101 00011110 00011111 00100000 00100001 00100010 00100011 00100100 00100101 00100110 00100111 00101000 00101001 00101010 00101011 Value NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SP ! " # $ % & ' ( ) * + Character (Null char.) (Start of Header) (Start of Text) (End of Text) (End of Transmission) (Enquiry) (Acknowledgment) (Bell) (Backspace) (Horizontal Tab) (Line Feed) (Vertical Tab) (Form Feed) (Carriage Return) (Shift Out) (Shift In) (Data Link Escape) (XON) (Device Control 1) (Device Control 2) (XOFF)(Device Control 3) (Device Control 4) (Negative Acknowledgments) (Synchronous Idle) (End of Trans. Block) (Cancel) (End of Medium) (Substitute) (Escape) (File Separator) (Group Separator) (Request to Send) (Record Separator) (Unit Separator) (Space) (exclamation mark) (double quote) (number sign) (dollar sign) (percent) (ampersand) (single quote) (left/opening parenthesis) (right/closing parenthesis) (asterisk) (plus)

Number Systems

Contd....

27

Computer Organization and Architecture

044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095

054 055 056 057 060 061 062 063 064 065 066 067 070 071 072 073 074 075 076 077 100 101 102 103 104 105 106 107 110 111 112 113 114 115 116 117 120 121 122 123 124 125 126 127 130 131 132 133 134 135 136 137

02C 02D 02E 02F 030 031 032 033 034 035 036 037 038 039 03A 03B 03C 03D 03E 03F 040 041 042 043 044 045 046 047 048 049 04A 04B 04C 04D 04E 04F 050 051 052 053 054 055 056 057 058 059 05A 05B 05C 05D 05E 05F

00101100 00101101 00101110 00101111 00110000 00110001 00110010 00110011 00110100 00110101 00110110 00110111 00111000 00111001 00111010 00111011 00111100 00111101 00111110 00111111 01000000 01000001 01000010 01000011 01000100 01000101 01000110 01000111 01001000 01001001 01001010 01001011 01001100 01001101 01001110 01001111 01010000 01010001 01010010 01010011 01010100 01010101 01010110 01010111 01011000 01011001 01011010 01011011 01011100 01011101 01011110 01011111

, . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _

(comma) (minus or dash) (dot) (forward slash)

(colon) (semi-colon) (less than) (equal sign) (greater than) (question mark) (AT symbol)

(left/opening bracket) (back slash) (right/closing bracket) (caret/circumflex) (underscore) Contd...

28

096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

140 141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160 161 162 163 164 165 166 167 170 171 172 173 174 175 176 177

060 061 062 063 064 065 066 067 068 069 06A 06B 06C 06D 06E 06F 070 071 072 073 074 075 076 077 078 079 07A 07B 07C 07D 07E 07F

01100000 01100001 01100010 01100011 01100100 01100101 01100110 01100111 01101000 01101001 01101010 01101011 01101100 01101101 01101110 01101111 01110000 01110001 01110010 01110011 01110100 01110101 01110110 01110111 01111000 01111001 01111010 01111011 01111100 01111101 01111110 01111111

` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ DEL (left/opening brace) (vertical bar) (right/closing brace) (tilde) (delete)

Number Systems

1.7.3 Excess-3 Code


This is a variant of BCD representation. It is obtained from the BCD code by adding the binary code for 3 (110) to it. The following table presents the codes. Decimal digit 0 1 2 3 4 5 6 7 8 9 BCD Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 Excess-3 Code(= BCD + 0110) 0110 0111 1000 0101 1010 1011 1100 1111 1110 1111
29

Computer Organization and Architecture

Thus, 475D = 0100 0111 0101BCD = 1010 1111 1011Excess-3

1.7.4 Gray Code


Representing decimal numbers by their binary equivalent serves the purpose well. However, there are certain problems involved when this is employed in counting. Look at the counting in binary number listed below and note the number of bits changing between any two consecutive numbers (assuming that we are using 4 bits for the numbers). Decimal 0 1 2 3 4 5 6 7 8 Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1 2 (1 to 0 and 0 to 1) 1 3 (0 to 1, 1 to 0 and 1 to 0) 1 2 (0 to 1 and 1 to 0) 1 4 (0 to 1, 1 to 0, 1 to 0 and 1 to 0) Number of bits changed

And so on. Note that when one counts from 0111B (7 decimal) to 1000B (8 decimal), 4 bits change simultaneously before it is read. If all the bits do not undergo simultaneous change, as it may happen in some implementations of hardware, the number generated will not be correct. To avoid such situations Gray code scheme has been developed. In Gray code only one bit changes between consecutive numbers. There are two simple rules to construct the gray code. First start with all 0s and then proceed by changing the least significant bit (lsb) which will represent next number. Here are the first 16 Gray coded numbers. Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
30

Gray Code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000

In order to convert a Gray-coded number to binary equivalent use the following method. 1. Since binary number and the Gray-coded number have the same number of bits, therefore, reserve as many bits in the binary form as there are bits in the Gray code. Also, left-hand bit (Most Significant Bit) of both binary and Gray code remain always the same. Therefore copy the MSB of Gray coded number to that into the binary equivalent. Add the binary MSB and the gray code next-to-MSB to obtain the bit next to MSB of binary ignoring any carry. Repeat step-3 until all the bits have been obtained.

Number Systems

2.

3. 4.

Example: Convert 10011011Gray to its binary equivalent. Solution: 1. 2. 3. The number of bits in this code is 8. Therefore, in the binary equivalent there will be 8 bits. Let the number be [][][][][][][][]B. MSB of both codes will be the same. The MSB of the given Gray code is 1, the required binary becomes [1][][][][][][][]B. 2nd bit = (2nd bit)Gray + (1st bit)B =0+1=1 The number becomes [1][1][][][][][][]B. 4. 3rd bit = (3rd bit)Gray + (2nd bit)B =0+1=1 The number becomes [1][1][1][][][][][]B. 5. 4th bit = (4th bit)Gray + (3rd bit)B =1+1=0 ignoring the carry bit.

The number becomes [1][1][1][0][][][][]B. 6. 5th bit = (5th bit)Gray + (4th bit)B =1+0=1 The number becomes [1][1][1][0][1][][][]B. 7. 6th bit = (6th bit)Gray + (5th bit)B =0+1=1 The number becomes [1][1][1][0][1][1][][]B. 8. 7th bit = (7th bit)Gray + (6th bit)B =1+1=0 ignoring carry.

The number becomes [1][1][1][0][1][1][0][]B. 9. 8th bit = (8th bit)Gray + (7th bit)B =1+0=1 The number becomes [1][1][1][0][1][1][0][1]B. Thus the required binary equivalent is 11101101B.

31

Computer Organization and Architecture

Check Your Progress 2

1.

Name some types of Binary Codes. ............................................................................................................. .............................................................................................................

2.

What is the difference between ASCII and EBCDIC? ............................................................................................................. .............................................................................................................

1.8 LET US SUM UP


This unit completes our discussion on the Number System. Different number systems include decimal number system with radix 10, Binary number system with radix 2, Octal number System with radix 8 and Hexadecimal number system with radix 16. All the number systems can be inter-converted to one another. Two types of complements for a number of base r are discussed including rs complement and (r1)s complement. All the arithmetic operations (+, , , /) in binary system are performed in the same way as in decimal number system and are discussed in this unit. Last but not the least, various types of binary codes including BCD, EBCDIC, ASCII, Excess-3 code, and gray code are discussed. Conversion from Gray code to BCD is also discussed.

1.9 LESSON END ACTIVITIES


1. 2. 3. Convert ( 2AC5.D)16 to decimal, binary and octal. What floating point number does 0100101000.010101 represent? The following is a message encoded in ASCII code. What is the message? 1001000 1000101 1001100 1010000

1.10 KEYWORDS
Non-Positional Number System: Method of counting things using stones and pebbles in ancient time. Positional Number System: Number system containing few digits to perform counting and calculations. Decimal Number System: Our present number system with a base or radix of 10, based on the use of ten different digits (09), known as Arabic Numerals. Binary Number System: A number system that users only two digits, i.e., 0 and 1 and has a base of 2. Octal Number System: A number system with base or radix of 8, using digits 0 to 7. Each digit is represented by 3 bits. Hexadecimal Number System: A number system with base of 16, using digits 0 to 9 and A, B, C, D, E, F where decimal values of A to F are 10 to 15 respectively. Each digit is represented by 4 bits. BCD (Binary Coded Decimal): Coding scheme where every decimal digit (0,1,2,.....9) are uniquely represented by 4 bits (a nibble).
32

EBCDIC (Extended Binary Coded Decimal Interchange Code): Coding scheme developed by IBM as an extension of BCD, which extends BCD from 4 bits to 8 bits. ASCII (American Standard Code for Information Interchange): A 7-bit coding scheme very similar to EBCDIC. Excess-3 Code: A variant of BCD representation, obtained from the BCD code by adding the binary for 3(110) to it.

Number Systems

1.11 QUESTIONS FOR DISCUSSION


1. 2. Convert the decimal number 250.5 into octal and hexadecimal number system. Convert the following decimal numbers to binary: a. b. c. d. 3. 4. 5. 6. 7. 12.0625 673.23 10000 1998

Convert (225.225)10 to binary, octal and hexadecimal. Convert (11010111.110)2 to decimal, octal and hexadecimal. Convert (623.77)8 to decimal, binary and hexadecimal. Convert ( 2AC5.D)16 to decimal, octal and hexadecimal. Convert the following binary numbers to the decimal numbers: a. b. c. d. 10.10001 101110.0101 1110101.110 1101101.111

Check Your Progress: Model Answers Ans. 1


1. The positional number system contains a few digits only, just like Decimal Number system contains 10 digits (0, 1, 2,............., 8, 9) and binary number system contains two digits (0 and 1) only. The method of counting uses an additive approach and is called the Non-Positional Number System. 2. (i) Our present number system with a base or radix of 10 is based on the use of ten different digits (0-9), known as Arabic numerals. The highest numerical symbol, i.e. 9 has a value one less than the base for the decimal number system. Binary number system uses only two digits, i.e. 0 and 1 and has a base of 2. All decimal numbers can be represented using the combination of these two digits only.

(ii)

(iii) A number system with base or radix of 8 is known as octal number system. Digits used in this number system are 0 to 7. For the representation of octal number in binary number systems, 3 bits are required to represent each digit of octal numbers system.
Contd....
33

Computer Organization and Architecture

(iv) Hexadecimal is a number system with base of 16. Digits used in this number system are 0 to 9 and A, B, C, D, E, F where decimal values of A to F are 10 to 15 respectively.

Ans. 2
1. 2. Binary codes are: EBCDIC code, BCD code, Excess-3 code and Gray code. ASCII (American Standard Code for Information Interchange): A 7-bit coding scheme very similar to EBCDIC. EBCDIC (Extended Binary Coded Decimal Interchange Code): Coding scheme developed by IBM as an extension of BCD, which extends BCD from 4 bits to 8 bits.

1.12 SUGGESTED READINGS


Langholx, Kandel, Gideon Longholx, Abraham Kandel, Joe L. Mott, Foundations of Digital Logic Design, World Scientific Farhat A. Farhat, Hassan A. Farhat, Digital Design and computer Organization, CRC Press

34

Das könnte Ihnen auch gefallen