End Show UNIT – 2Data Representation and Internal Operations of the Computer.

176
End Show UNIT – 2 Data Representation and Internal Operations of the Computer

Transcript of End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Page 1: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

UNIT – 2 Data Representation and Internal Operations of the Computer

Page 2: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Unit 2 – Data Representation and Internal Operations of the Computer

2.1 Introduction to Number Systems

2.2 Data Representation

2.3 Logic Gates and Circuits

2.4 Boolean Algebra

Page 3: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Some ancient numerals

Page 4: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Some ancient numerals

Page 5: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowEgyptian 3rd Century BC

Page 6: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Some ancient numerals

Page 7: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowCretan 1200-1700BC

Page 8: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

England’s “five-barred gate”

Page 9: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowThe Greek Numeral System

Page 10: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowComputation with Greek Numeral System

Indo-Arabic Indo-Arabic

Page 11: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Roman Numerals1 I 20 XX2 II 25 XXV3 III 29 XIX4 IV 50 L5 V 75 LXXV6 VI 100 C10X 500 D11XI 1000M16XVI

Now try these:

1. XXXVI2. XL3. XVII4. DCCLVI5. MCMLXIX

Page 12: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

5What is this ?

This is also a symbol

Why do we use this symbol ?

To represent quantity

Five (5)

Page 13: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

0

1

2

3

4

5 10

9

8

7

6

Symbols to represent certain quantities

Page 14: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow do you represent this quantity on a spike abacus?

0000

Page 15: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

100

How do you represent this quantity

Page 16: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

200

Page 17: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

300

Page 18: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

400

Page 19: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

500

Page 20: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

600

Page 21: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

700

Page 22: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

800

Page 23: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

900

Page 24: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

900

Page 25: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

010

Page 26: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

010

Page 27: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

110

Page 28: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHow Represent This Quantity

2100101……… 102

Page 29: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowAbacus

Roman Abacus

Chinese Abacus

JapaneseSoroban (Abacus)

Abacus is a Latin word, related to the Greek “abax”, meaning table. The word `calculus’ originally meant pebble in Latin, used on the counting board.

Page 30: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show2.1 – Introduction to the Number System

• A number system defines a set of symbols used to represent quantity.

• Quantifying values and items in relation to each other is helpful us to make sense of our

environment.

• The study of number system is not just limited to computers. We use numbers every day. A computer manipulates and stores numbers inside the computer system.

Page 31: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowWhy we learn it?

These symbols are processed internally by components that can maintain a limited number of discrete states.

To represent these states we have to use number systems.

– Ex: The decimal digits 0,1,2, …..,9 provide 10 discrete symbols (10 digits)

Page 32: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowDecimal Number system – Place Values

Hundreds Tens Ones

We normally use the decimal number system to represent quantities and perform calculations.

3 x 100 4 x 10 2 x 1

342

Page 33: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 3 x 1

343

Page 34: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 4 x 1

344

Page 35: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 5 x 1

345

Page 36: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 6 x 1

346

Page 37: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 7 x 1

347

Page 38: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 8 x 1

348

Page 39: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 4 x 10 9 x 1

349

Page 40: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hundreds Tens Ones

3 x 100 0 x 1 5 x 10

350

Page 41: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Consider this number format 53410

The Base of the Decimal number here is 10

Normally we don’t write base numbers in decimal form

We can use digits 0 - 9

Page 42: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowFace Value and Place value

Weighing Factor The weighing factor is the multiplier value applied to each column position of the number.

For instance, a decimal has a weighing factor of TEN, in that each column on the immediate left indicates an increase in value by a multiple of 10.

i.e.; each column moves to the left increasing by a multiple of 10.

312 = 300 + 10 + 2

= 3 * 100 + 1 * 10 + 2 * 1

= 3 * 102 + 1 * 101 + 2 * 100 Weighing factors

Page 43: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

The decimal Number System: • uses base 10• includes only the symbols 0 through 9

The weighed values for each position is as follows:

104 103 102 101 100 10-1 10-2 10-3

10000 1000 100 10 1 .1 .01 .001

Decimal Number System(cont..)

Page 44: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

• This number system uses TEN different symbols to represent values. The set values used in decimal are

0 1 2 3 4 5 6 7 8 9

Lowest value Highest value

Decimal number system (cont..)

When doing a calculation, if the highest digit (9) is exceeded, a carry over transferred to the next column (to the left) occurs.

Lets 17+41718 +119 +220 +321 +4

When 9 is exceeded, we reset (0), and carry a value of 1 to the next column on the left

Page 45: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowBinary number system

TWO symbols are used to represent numerals in the binary number system. These have the values of,

0 1

0 represents low value, and 1 represents high value.

Position x……………

…..5 4 3 2 1

Binary Value 1……………

…1 1 1 1 1

Decimal Value

2 x-1 ……………….

24 23 22 21 20

Page 46: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowMore illustration…..

The binary number system is also known as

the base 2 number system.

The values of the positions are calculated by

raising 2 to some power.

Why is 2 the base in binary numbers?

Because we use 2 digits, the digits 0 and 1.

Page 47: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowBinary Number System (con’t)

• The binary number system is also a positional numbering system.

• Instead of using ten digits, 0 - 9, the binary system uses only two digits, 0 and 1.

Example of a binary number and the position values :

1 0 0 1 1 0 1 26 25 24 23 22 21 20

Page 48: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

4 1

1 x 22 0 x 21 1 x 20 0 x 23

Representation of the binary number 0101

Position x 4 3 2 1

Binary Value 1 0 1 0 1

Decimal Value

2 x-1 23 22 21 20

Page 49: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

• uses base 2

• includes only the digits 0 and 1

The weighted values for each position is as follows:

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

Binary Number System(cont…)

Page 50: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowOctal number system

The octal number system uses EIGHT symbols to represent numbers. The 8 distinct symbols are,

0 1 2 3 4 5 6 7

With 0 having the lowest value and 7 having the highest value

Columns are used in the same way as in the decimal system in that, the left most column is used to represent the greatest value

Octal numbers are represented with the base 8

Page 51: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

3 x 82 1 x 81 4 x 80 0 x 83

Representation of octal number 314

64

64

64

8 1111

Page 52: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

The Octal system is based on the binary system with a 3-bit boundary. The Octal Number System:

• uses base 8 • includes only the symbols 0 through 7

85 84 83 82 81 80

32768 4096 512 64 8 1

The weighted values for each position is as follows:

Octal Number System

Page 53: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHexadecimal number system

• The hexadecimal number system uses SIXTEEN symbols to represent Numbers. The 16 distinct symbols are, 0 1 2 3 4 5 6 7 8 9 A B C D E F, where A = 10, B = 11, .., F = 15

• With ‘0’ having the lowest value and ‘F’ having the highest value.

• Hexadecimal numbers are represented with the base 16.

Page 54: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

1 x 162 4 x 161 F(15) x 160 0 x 163

Representation of hexadecimal number 34F

256

256

16 111111111111111

16

16

16

256

Page 55: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowThe Hexadecimal Number System:

uses base 16

• includes only the symbols 0 through 9 and the letters A, B, C, D, E, and F to represent 10, 11, 12, 13, 14, and 15 respectively.

163 162 161 160

4096 256 16 1

The weighted values for each position is as follows:

Page 56: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Binary to Decimal

Multiply each digit by its weighted position, and add each of the weighted values.

2.1.2 Number Base Conversion

Example

The binary value 1011 represents:

1x23 + 0x22 + 1x21 + 1x20

=1x8 + 0x4 + 1x2 + 1x1

=8 + 0 + 2 + 1

=11 (base 10)

Page 57: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowConverting from Binary to Decimal

1 0 0 1 1 0 1 26 25 24 23 22 21 20

20 = 1 24 = 16 21 = 2 25

= 32 22 = 4 26 = 64 23 = 8

1 X 20 = 10 X 21 = 0 1 X 22 = 4 1 X 23 = 8 0 X 24 = 00 X 25 = 01 X 26 = 64

7710

Page 58: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder Binary Number

47 / 2 23 1 1 2 47

23 --1

Decimal to Binary (Repeated Division By 2)

Page 59: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder Binary Number

47 / 2 23 1 1

23 / 2 11 1 112 47

2 23 --1

11 --1

Decimal to Binary (Repeated Division By 2)

Page 60: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder Binary Number

47 / 2 23 1 1

23 / 2 11 1 11

11 / 2 5 1 111

2 47

2 23 --1

2 11 --1

5 --1

Decimal to Binary (Repeated Division By 2)

Page 61: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder Binary Number

47 / 2 23 1 1

23 / 2 11 1 11

11 / 2 5 1 111

5 / 2 2 1 1111

2 47

2 23 --1

2 11 --1

2 5 --1

2 --1

Decimal to Binary (Repeated Division By 2)

Page 62: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder Binary Number

47 / 2 23 1 1

23 / 2 11 1 11

11 / 2 5 1 111

5 / 2 2 1 1111

2 / 2 1 0 01111

2 47

2 23 --1

2 11 --1

2 5 --1

2 2 --1

1 --0

Decimal to Binary (Repeated Division By 2)

Page 63: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder Binary Number

47 / 2 23 1 1

23 / 2 11 1 11

11 / 2 5 1 111

5 / 2 2 1 1111

2 / 2 1 0 01111

1 / 2 0 1 101111

2 47

2 23 --1

2 11 --1

2 5 --1

2 2 --1

2 1 --0

0 --14710 = 1011112

Decimal to Binary (Repeated Division By 2)

Page 64: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Ex. Lets find the binary equivalent of the

decimal number 254

• 254 / 2 gives 127 with remainder 0

Page 65: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

• Lets find the binary equivalent of the

decimal number 254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

Page 66: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the

decimal number 254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

Page 67: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the decimal

number 254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

• 31 / 2 gives 15 with remainder 1

Page 68: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the decimal

number 254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

• 31 / 2 gives 15 with remainder 1

• 15 / 2 gives 7 with remainder 1

Page 69: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the decimal number

254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

• 31 / 2 gives 15 with remainder 1

• 15 / 2 gives 7 with remainder 1

• 7 / 2 gives 3 with remainder 1

Page 70: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the decimal

number 254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

• 31 / 2 gives 15 with remainder 1

• 15 / 2 gives 7 with remainder 1

• 7 / 2 gives 3 with remainder 1

• 3 / 2 gives 1 with remainder 1

Page 71: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the decimal

number 254

• 254 / 2 gives 127 with remainder 0

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

• 31 / 2 gives 15 with remainder 1

• 15 / 2 gives 7 with remainder 1

• 7 / 2 gives 3 with remainder 1

• 3 / 2 gives 1 with remainder 1

• 1 / 2 gives 0 with remainder 1

111111102

Page 72: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show• Lets find the binary equivalent of the decimal number 254

• 254 / 2 gives 127 with remainder 0 LSB

• 127 / 2 gives 63 with remainder 1

• 63 / 2 gives 31 with remainder 1

• 31 / 2 gives 15 with remainder 1

• 15 / 2 gives 7 with remainder 1

• 7 / 2 gives 3 with remainder 1

• 3 / 2 gives 1 with remainder 1

• 1 / 2 gives 0 with remainder 1 MSB

111111102

Page 73: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowBinary to Octal Conversion

It is easy to convert a binary number to an octal. This is accomplished by:

1010111012

001 010 111 110 110 010

1 2 7 6 6 2

Most Significant Bit (MSB)

Least Significant Bit (LSB)

1. Break the binary number into 3-bit sections from the LSB to the MSB.

2. Convert the 3-bit binary number to its octal equivalent.

For example, the binary value 1010111110110010 will be written:

Page 74: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowConversion from Binary to Octal

• Convert 10110111 to octal.

• Each octal digit is represented by 3 binary bits. Split the binary number into groups of 3 bits, starting from the right. 

10 110 111= 2 = 6 = 7= 2678

Page 75: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Octal Binary (in 3 bits)

0 000

1 001

2 010

3 011

4 100

5 101

6 110

7 111

Relationship between binary and octal

Page 76: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowOctal to Decimal Conversion

To convert from Octal to Decimal, multiply the value in each position by its Octal weight and add each value.

Example, convert this octal 342 to decimal,

we can obtain the decimal value as follows:

3x82 4x81 2x80

3x64 4x8 2x1

192 32 2 192 + 32 + 2 = 226

3 x 82 4 x 81 2 x 80

1

1

8

8

8

8

64

64

64

Page 77: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Conversion from Octal to Decimal

• Convert 1768 to decimal.

• Each column represents a power of 8,  176 = 1 * 82 + 7 * 81 + 6 * 80

= (1 * 64) + (7 * 8) + (6 * 1) = 64 + 56 + 6

= 126

Page 78: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowDecimal to Octal Conversion

To convert decimal to octal is slightly more difficult. The typical method to convert from decimal to octal is repeated division by 8.

Repeated Division By 8

•For this method, divide the decimal number by 8, and write the remainder on the side as the least significant digit.

•This process is continued by dividing the quotient by 8 and writing the remainder until the quotient is 0.

Page 79: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowDecimal to Octal Conversion

To convert decimal to octal is slightly more difficult. The typical method to convert from decimal to octal is repeated division by 8.

Repeated Division By 8

•For this method, divide the decimal number by 8, and write the remainder on the side as the least significant digit.

•This process is continued by dividing the quotient by 8 and writing the remainder until the quotient is 0.

Division Quotient Remainder 87 / 8 10 7

Page 80: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowDecimal to Octal Conversion

To convert decimal to octal is slightly more difficult. The typical method to convert from decimal to octal is repeated division by 8.

Repeated Division By 8

•For this method, divide the decimal number by 8, and write the remainder on the side as the least significant digit.

•This process is continued by dividing the quotient by 8 and writing the remainder until the quotient is 0.

Division Quotient Remainder 87 / 8 10 7

10 / 8 1 2

Page 81: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowDecimal to Octal Conversion

To convert decimal to octal is slightly more difficult. The typical method to convert from decimal to octal is repeated division by 8.

Repeated Division By 8

•For this method, divide the decimal number by 8, and write the remainder on the side as the least significant digit.

•This process is continued by dividing the quotient by 8 and writing the remainder until the quotient is 0.

Division Quotient Remainder 87 / 8 10 7

10 / 8 1 2

1 / 8 0 18710 = 1278

Page 82: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowBinary to Hexa Conversion

It is easy to convert a binary number to hexa. This is accomplished by:

1.Break the binary number into 4-bit sections from the LSB to the MSB.

2.Convert the 4-bit binary number to its Hexa equivalent.

For example, the binary value 1010111110110010 is written:

1010 1111 1011 0010

A F B 2

Page 83: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Conversion from binary to hexadecimal

• Convert 10110 to hexadecimal.

• Each hexadecimal digit represents 4 binary bits. Split the binary number into groups of 4 bits, starting from the right. 

1 0110 1 6=16 in hexadecimal

Page 84: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Hexadecimal Binary (in 4 bits)

Hexadecimal Binary (in 4 bits)

0 0000 8 1000

1 0001 9 1001

2 0010 A 1010

3 0011 B 1011

4 0100 C 1100

5 0101 D 1101

6 0110 E 1110

7 0111 F 1111

Relationship between Binary and Hexadecimal

Page 85: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHexa to Binary Conversion

It is also easy to convert from an integer hexa number to binary. This is accomplished by:

Convert the Hexa number to its 4-bit binary equivalent. Combine the 4-bit sections by removing the spaces.

B 2

1011 0010

This yields the binary number 10110010 or 1011 0010 in our more readable format.

For example the hexa value B2 is written in binary:

Page 86: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowHexadecimal to Decimal Conversion

To convert from Hexa to Decimal, multiply the value in each position by its hexa weight and add each value.

Using the value from the previous example, B216, we can obtain the decimal value as follows:

B x 161 2 x 160

11 x 16 2 x 1

176 2

176 + 2 = 178

0 x 162 11 x 161 2 x 160 0 x 163

1

1

1616161616161616161616

Page 87: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Conversion from hexadecimal to decimal

• Convert hexadecimal 17616 to decimal.

• Each column represents a power of 16,  17616= (1 * 162) + (7 * 161) + (6 * 160)

= (1 * 256) + (7 * 16 )+ (6 * 1) = 256 + 112 + 6

= 374

Page 88: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowDecimal to Hexa Decimal Conversion

To convert decimal to hexa is slightly more difficult. The typical

method to convert from decimal to hexa is repeated division by

16.

Repeated Division By 16

For this method, divide the decimal number by 16, and write the

remainder on the right hand side as the least significant digit.

This process is continued by dividing the quotient by 16 and writing

the remainder until the quotient is 0.

Page 89: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Ex: Convert decimal 2811 to hexa as follows:

Division Quotient Remainder 2811 / 16 175 11 = B

Page 90: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder 2811 / 16 175 11 = B

175 / 16 10 15 = F

Ex: Convert decimal 2811 to hexa as follows:

Page 91: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder 2811 / 16 175 11 = B

175 / 16 10 15 = F

10 / 16 0 10 = A

Ex: Convert decimal 2811 to hexa as follows:

Page 92: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

Division Quotient Remainder 2811 / 16 175 11 = B

175 / 16 10 15 = F

10 / 16 0 10 = A

Ex: Convert decimal 2811 to hexa as follows:

281110 = AFB16

Page 93: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

What is BIT (BINARY DIGIT)?

A bit is the smallest element of information used in a computer

A bit holds ONE of TWO possible values,

2.2 Data Representation

A bit which is OFF is also considered to be FALSE or NOT SET; a bit which is ON is also considered to be TRUE or SET

Only one of two values(0 or 1) can be stored in a single bit.

Page 94: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowWith a single bit, you can represent any two distinct items.

Examples

one or zero

true or false

on or off

male or female

right or wrong

Page 95: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

H 01001000

HASCII CODE IS 72

Data Representation

Page 96: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowWhat is Byte ?Bytes are a grouping of 8 bits

A byte is the smallest addressable datum (data item) in the memory by the microprocessor.

Page 97: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

The Binary equivalent of the decimal number 205 is as follows and the Most Significant Bit(MSB) and the Least Significant Bit (LSB)can be defined as below :

1 1 0 0 1 1 0 1

MSB

LSB

b7 b6 b5 b4 b3 b2 b1 b0

Most Significant Bit (MSB) Least Significant Bit (LSB)

1 0 0 1 1 0 0 1

The bits in a byte are filled from LSB (b0) to MSB (b7) respectively as follows:

Page 98: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowSince a byte consists of eight bits, it can represent 28, or 256,

different values. Generally, we use a byte to represent:

Unsigned numeric values in the range 0 to 255

Signed numbers in the range -128 to +127

ASCII(American Standard Code for Information Interchange)

character codes

Other special data types requiring no more than 256

different values.

Many data types have fewer than 256 items so eight bits is

usually adequate.

Page 99: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowCapacity of Various Units

8 bits = 1Byte

(2 10) 1024 Byte = 1 KB (kilobyte)

(210) 1024 KB = 1 MB (Megabyte)

(210) 1024 MB = 1 GB (Gigabyte)

(210 ) 1024 GB = 1 TB (Terabyte)

Unit conversion

1kiloByte = 210 bytes

1MegaByte= 220 bytes

1GigaByte = 230 bytes

1TeraByte = 240 bytes

Page 100: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

2.2.2 Coding Systems

1. BCD (Binary Coded Decimal)

2. ASCII

(American Standard Code for Information Interchange)

Page 101: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowBCD - Binary Corded Decimal

@ Binary Coded Decimal is a numerical code.

@ In this code structure, each of the decimal digits (0-9) is represented by a four-bit binary code (eg: 3 is represented by 0011)

@ Each digit is then represented by it's binary equivalent.

@ 16 unique(different) numbers can be stored in the 4 bit binary code.

@ Thus there are 6 invalid four-bit combinations in the BCD code.

Page 102: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

This makes BCD easy to read, but it is not very efficient in

terms of storage space, nor is it as efficiently processed in

hardware.

3 8 6

0011 1000 0110

The number 386 is coded in BCD as follows:

BCD code is 001110000110

The number 59 is coded in BCD as follows

5 9

0101 1001 BCD code is 01011001

Page 103: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowCont… BCD

Decimal BCD

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

8 1000

9 1001

Decimal BCD

10 1010

11 1011

12 1100

13 1101

14 1110

15 1111

Valid Combinations Invalid Combinations

Page 104: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End ShowCont ….BCD

Converting the Decimal value 546 to BCD

5 = 01014 = 01006 = 0110

Thus 54610 = 0101010001102

Converting the binary value 011100010101 to decimal is

0111 = 70001 = 10101 = 5

Thus 0111000101012 = 71510

Page 105: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

ASCII - The American Standard Code for Information Interchange

• The American National Standards Institute has published an American Standards Code for Information Interchange(ASCII)

• This code is now most widely used by major manufactures. so that their equipment will be compatible with those of other manufactures.

Page 106: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

ASCII is a computer code which uses 128

different coding combinations of a group of

seven bits (27= 128) to represent

• Characters A to Z, both upper and lower case

• Special characters, < , ., ?, : ,etc.,

• Numbers 0 to 9

• Special control codes used in device control

Page 107: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

HEX DEC CHAR

41 65 A

42 66 B

43 67 C

44 68 D

- - -

- - -

- - -

- - -

58 88 X

59 89 Y

5A 90 Z

HEX DEC CHAR

61 97 a

62 98 b

63 99 c

64 100 d

- - -

- - -

- - -

- - -

78 120 x

79 121 y

7A 122 z

HEX DEC CHAR

30 48 0

31 49 1

32 50 2

33 51 3

34 52 4

35 53 5

36 54 6

37 55 7

38 56 8

39 57 9

The tables below gives the ASCII character set :-

Page 108: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show

ASCII (Cont……)

Example Code the text string 'Hello.' in ASCII using hexadecimal digits.

H = 48

e = 65

l = 6C

l = 6C

o = 6F

. = 2E

Thus the string is represented by the byte sequence

48 65 6C 6C 6F 2E

Page 109: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Where are we?

2.3 Logic Gates and Circuits

End Show

Page 110: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

A logic gate is an elementary building block of a digital circuit. Most logic gates have two inputs and one output.

At any given moment, every terminal is in one of the two binary conditions low (0) or high (1), represented by different voltage levels.

In most logic gates, the low state is approximately zero volts (0 V), while the high state is approximately five volts positive (+5 V).

There are seven basic logic gates: AND, OR, XOR, NOT, NAND, NOR, and XNOR.

End Show

Page 111: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Logic gates are small (several micron) structures which take one or more bits as input, and produce another bit as output

Different logic gates use different techniques to calculate their output

End Show

Page 112: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

The most common logic gates used perform the following logic functions:

AND : Output is True(1) if all inputs are True (1)

OR : Output is False (0) if all inputs are False (0)

NOT : Output is the opposite of the single input

i.e., If input is true (1) the output is false (0)

If input is false (0) the output is true (1) End Show

Page 113: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

The AND gate has two or more inputs.

The output from the AND gate is 1 if and only if all of the

inputs are 1, otherwise the output from the gate is 0.

The AND gate is drawn as follows

AND - Gate

A

B

F=A.B

+ -A B

A.B

End Show

Page 114: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

End Show

Page 115: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

0

End Show

Page 116: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

0

End Show

Page 117: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

0

End Show

Page 118: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

0

0

End Show

Page 119: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

0

End Show

Page 120: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

1

End Show

Page 121: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

1

0

End Show

Page 122: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

0

End Show

Page 123: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

1

End Show

Page 124: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

1

1

End Show

Page 125: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

1

End Show

Page 126: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Truth table for AND gate

A B A.B

0 0 0

0 1 0

1 0 0

1 1 1

The output from the AND gate is written as A.B

The truth table for a two-input AND gate looks like

00

F=0

01

F=0

10

F=0

11

F=1

End Show

Page 127: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

OR-Gate

A

B

F=A+B

+ -

The OR gate has two or more inputs.

The output from the OR gate is 1 if any of the inputs is 1.

The gate output is 0 if and only if all inputs are 0.

The OR gate is drawn as follows

A

B A+B

End Show

Page 128: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

End Show

Page 129: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

0

End Show

Page 130: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

End Show

Page 131: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

End Show

Page 132: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

0

End Show

Page 133: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

0

End Show

Page 134: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 135: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 136: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

1

End Show

Page 137: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

1

End Show

Page 138: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 139: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 140: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

1

End Show

Page 141: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

1

End Show

Page 142: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 143: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 144: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

A B A+B

0 0 0

0 1 1

1 0 1

1 1 1

The output from the OR gate is written as A+B

The truth table for a two-input OR gate looks like

0

0F=0

0

1F=1

1

0F=1

1

1F=1

Truth table for OR gate

End Show

Page 145: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

NOT-Gate

The input to the NOT gate A is inverted

i.e. The binary input state of 0 gives an output of 1 and the binary input state of 1 gives an output of 0.

Ā is known as "NOT A" or alternatively as the complement of A.

A Ā

0 11 0

The NOT gate is unique in that it only has one input. It looks like

AA ĀĀ

End Show

Page 146: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Logic Gates from Transistors• For example, we will build a NOT gate from a

transistor.

Transistor

extrapowersource

Input toNOT gate.

Output fromNOT gate.

End Show

Page 147: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Logic Gates from Transistors• For example, we will build a NOT gate from a

transistor.

TransistorOFF

extrapowersource

NOT 1 0

Input toNOT gateis ON.

Output fromNOT gateis OFF.

End Show

Page 148: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Logic Gates from Transistors• For example, we will build a NOT gate from a

transistor.

TransistorON

extrapowersource

NOT 0 1

Input toNOT gateis OFF.

Output fromNOT gateis ON.

End Show

Page 149: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

End Show

Page 150: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

End Show

Page 151: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 152: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 153: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 154: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

1

End Show

Page 155: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

End Show

Page 156: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

0

End Show

Page 157: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

NAND-Gate

The truth table for a two-input

NAND gate looks like

A B P

0 0 1

0 1 1

1 0 1

1 1 0

BAP .

A

B

BAP .

End Show

Page 158: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

NOR-Gate

The truth table for a two-

input NOR gate looks like

A B P

0 0 1

0 1 0

1 0 0

1 1 0

BAP A

B

End Show

Page 159: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

XOR-Gate

The truth table for a two-

input XOR gate looks like

A B P

0 0 0

0 1 1

1 0 1

1 1 0

A

B

End Show

A BP

BAP

Page 160: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

2.4 Boolean Algebra

A set of rules formulated by the English mathematician George Boole describe certain propositions whose outcome would be either true or false. With regard to digital logic, these rules are used to describe circuits whose state can be either, 1 (true) or 0 (false).

In order to fully understand this, the relation between the AND gate, OR gate and NOT gate operations should be appreciated.

George Boole

End Show

Page 161: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Algebra: variables, values, operations

In Boolean algebra, the values are the symbols 0 and 1If a logic statement is false, it has value 0If a logic statement is true, it has value 1

Operations: AND, OR, NOT.

2.4.1 Basic Laws in Boolean AlgebraEnd Show

Page 162: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

Laws of Boolean Algebra

(a) (a) A + B = B + AA + B = B + A

A B A+B

0 0 0

0 1 1

1 0 1

1 1 1

(b) (b) A.B = B.AA.B = B.A

A B A+B

0 0 0

0 1 0

1 0 0

1 1 1

T1 : Commutative LawT1 : Commutative Law

B A B+A

0 0 0

1 0 1

0 1 1

1 1 1

B A B+A

0 0 0

1 0 0

0 1 0

1 1 1

End Show

Page 163: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T2 : Associate Law T2 : Associate Law

(a) (A + B) + C = A + (B + C) (a) (A + B) + C = A + (B + C)

A B C (A+B)

(A+B)+C

0 0 0 0 0

0 0 1 0 1

0 1 0 1 1

0 1 1 1 1

1 0 0 1 1

1 0 1 1 1

1 1 0 1 1

1 1 1 1 1

A B C (B+C)

A+(B+C)

0 0 0 0 0

0 0 1 1 1

0 1 0 1 1

0 1 1 1 1

1 0 0 0 1

1 0 1 1 1

1 1 0 1 1

1 1 1 1 1

End Show

Page 164: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

(b) (A.B).C = A.(B.C) (b) (A.B).C = A.(B.C)

Associate Law contdAssociate Law contd……. …….

A B C (A.B) (A.B).C

0 0 0 0 0

0 0 1 0 0

0 1 0 0 0

0 1 1 0 0

1 0 0 0 0

1 0 1 0 0

1 1 0 1 0

1 1 1 1 1

A B C (B.C) A.(B.C)

0 0 0 0 0

0 0 1 0 0

0 1 0 0 0

0 1 1 1 0

1 0 0 0 0

1 0 1 0 0

1 1 0 0 0

1 1 1 1 1

End Show

Page 165: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T3 : Distributive LawT3 : Distributive Law

(a) A.(B + C) = A.B + A.C(a) A.(B + C) = A.B + A.C

A B C (B+C)

A.(B+C)

0 0 0 0 0

0 0 1 1 0

0 1 0 1 0

0 1 1 1 0

1 0 0 0 0

1 0 1 1 1

1 1 0 1 1

1 1 1 1 1

A B C AB AC AB+AC

0 0 0 0 0 0

0 0 1 0 0 0

0 1 0 0 0 0

0 1 1 0 0 0

1 0 0 0 0 0

1 0 1 0 1 1

1 1 0 1 0 1

1 1 1 1 1 1

End Show

Page 166: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

(b) A + (B.C) = (A + B) (A + C) (b) A + (B.C) = (A + B) (A + C)

A B C BC A+(BC)

0 0 0 0 0

0 0 1 0 0

0 1 0 0 0

0 1 1 1 1

1 0 0 0 1

1 0 1 0 1

1 1 0 0 1

1 1 1 1 1

A B C (A+B)

(A+C) (A+B).(A+C)

0 0 0 0 0 0

0 0 1 0 1 0

0 1 0 1 0 0

0 1 1 1 1 1

1 0 0 1 1 1

1 0 1 1 1 1

1 1 0 1 1 1

1 1 1 1 1 1

End Show

Page 167: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T4 : Identity Law T4 : Identity Law

(a) A + A = A (a) A + A = A

(b) A.A = A (b) A.A = A

A A P=A+A

0 0 0

1 1 1

A

0

1

A A P=A.A

0 0 0

1 1 1

A

0

1

End Show

Page 168: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T5 :(a) T5 :(a) ABAAB

A

0

0

1

10

1

0

1

1

0

0

0

AB

0

1

0

0

010

101

111

000

BA BA BAAB B

End Show

Page 169: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

ABABA .(b)

A

0

0

1

11

1

0

1

1

1

1

0

A+B

010

101

111

000

BA )).(( BABA BA

End Show

Page 170: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T6 : Redundance Law T6 : Redundance Law

(a) (a) A + A.B = AA + A.B = A

(b) (b) A.(A + B) = AA.(A + B) = A

A B A.B A+A.B

0 0 0 0

0 1 0 0

1 0 0 1

1 1 1 1

A

0

0

1

1

A B A+B

A.(A+B)

0 0 0 0

0 1 1 0

1 0 1 1

1 1 1 1

A

0

0

1

1

End Show

Page 171: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T7 :T7 :

(a) (a) 0 + A = A0 + A = A

(b) (b) 0 . A = 00 . A = 0

0 A 0+A

0 0 0

0 1 1

A

0

1

0 A 0.A

0 0 0

0 1 0

0

0

0

End Show

Page 172: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T8 :T8 :

(a) (a) 1 + A = 11 + A = 1

((b) b) 1 . A = A1 . A = A

1 A 1+A

1 0 1

1 1 1

1

1

1

1 A 1.A

1 0 0

1 1 1

A

0

1

End Show

Page 173: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

T9 : T9 : (a)(a) 1 AA

0. AA(b)(b)

A

0 1 1

1 0 1

1

1

1

A AA

A

0 1 0

1 0 0

0

0

0

A AA.

End Show

Page 174: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

• T10 :

BAA

BABAA

ABBAA )(

A B

0 0 1 0 0

0 1 1 1 1

1 0 0 0 1

1 1 0 0 1

A B A+B

0 0 0

0 1 1

1 0 1

1 1 1

BAA

)( BAA A B

0 0 1 1 0

0 1 1 1 0

1 0 0 0 0

1 1 0 1 1

A B A.B

0 0 0

0 1 0

1 0 0

1 1 1

BAA

End Show

Page 175: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

BABA .

BABA .

(a)

(b)

T11T11 : : De Morgan's TheoremDe Morgan's Theorem

1

1

1

0

A+B

0

0

0

1

10

01

11

00

BA BA A B

0 0 1 1 1

0 1 1 0 0

1 0 0 1 0

1 1 0 0 0

BABA .

A B BA.

A.B

1

0

0

0

0

1

1

1

10

01

11

00BA BA. A B

0 0 1 1 1

0 1 1 0 1

1 0 0 1 1

1 1 0 0 0

A B BA

End Show

Page 176: End Show UNIT – 2Data Representation and Internal Operations of the Computer.

End Show