Introduction to Computer Systems - Lecture 4 PDF

Document Details

DiligentCyclops

Uploaded by DiligentCyclops

Dr Islam Alkabbany

Tags

computer systems data representation number systems binary conversion

Summary

These lecture notes cover Module 4: Data Representation for an Introduction to Computer Systems course. The notes discuss different number systems, including decimal, binary, octal, and hexadecimal. Topics include conversion between these systems and examples.

Full Transcript

Introduction to Computer Systems Module 4: Data Representation Dr Islam Alkabbany Outlines Recognize the number systems. Learn the conversion from a number system to another one. Understand binary arithmetic. Floating point binary data representation. Text data repre...

Introduction to Computer Systems Module 4: Data Representation Dr Islam Alkabbany Outlines Recognize the number systems. Learn the conversion from a number system to another one. Understand binary arithmetic. Floating point binary data representation. Text data representation. Data Representation Data can be in the form of numbers, text, audio, image, video or a combination of these forms which is called multimedia. Any form of data must be represented by symbols 0 and 1 to be stored in or processed by computers. Encoding: The way the data could be represented into 0 and 1 Number System A number system in base (radix) r uses unique symbols for r digits. One or more digits are combined to get a number The digits of a number have two kinds of values: o Digit value o Position value The number is calculated as the sum of Digit * baseposition of each of the digits A number in a particular base is written as: (number)base Number of values could be represented in n digit is rn Number System Example: decimal which has base 10 has 10 digits values (0-9) X = (5432)10 X = 5*103 + 4*102 + 3*101 + 2*100 = 5*1000 + 4*100 + 3*10 + 2*1 =5432 Number of values could be represented in 4 digit = 104 Number Systems In computers, we are concerned with four kinds of number systems: Number Systems Example Decimal Number System: (512.49)10 (512.49)10 = 5x102 + 1x101 + 2x100 + 4x10-1 + 9x10-2 (512.49)10 = 5x100 + 1x10 + 2X1 +4x.1 + 9x.01 (512.49)10 = 512.49 Number Systems Example Octal Number System: (456.41)8 (456.41)8 = 4x82 + 5x81 + 6x80 + 4x8-1 + 1x8-2 (456.41)8 = 4*64 + 5*8 + 6*1 + 4/8 + 1/64 (456.41)8 = 302.515625 Number Systems Example Hexadecimal Number System: (1FA.4C)16 (1FA.4C)16 = 1x162 + 15x161 + 10x160 + 4x16-1 + 12x16-2 (1FA.4C)16 = 1*256 +15*16 +10*1+4/16 + 12/256 (1FA.4C)16 = 506.296875 Number Systems Example Binary Number System: (1101.01)2 (1101.01)2 = 1x23 + 1x22 + 0x21 + 1x20 + 0x2-1 + 1x2-2 (1101.01)2 = 1*8 +1*4 + 0*2 + 1*1 + 0/2 + + 1/4 (1101.01)2 = 13.25 Converting Decimal Integer to Binary, Octal, Hexadecimal A decimal integer is converted to any other base, by using the division operation (integer division) by the base of the new number system. Example: Convert (25)10 to binary, octal and Hexadecimal. Converting Decimal Integer to Binary Number base of Reminder (Quotient) new system 25 ÷2 1 LSB 12 ÷2 0 6 ÷2 0 3 ÷2 1 1 ÷2 1 MSB 0 End when last result =0 (25)10 = (11001)2 (11001)2 = 1x24 + 1x23 + 1x20 Converting Decimal Integer to Octal Number base of new Reminder (Quotient) system 25 ÷8 1 LSB 3 ÷8 3 MSB 0 End when last result =0 (25)10 = (31)8 (31)8 = 3x81 + 1x80 Converting Decimal Integer to Hexadecimal Number base of new Reminder (Quotient) system 25 ÷16 9 LSB 1 ÷16 1 MSB 0 End when last result =0 (25)10 = (19)16 (19)16 = 1x161 + 9x160 Converting Decimal Fraction to Binary, Octal, Hexadecimal A decimal fraction is converted to any other base, by using the multiplication operation by the base. Example: Convert (0.2345)10 to binary, octal and hexadecimal Converting Decimal Fraction to Binary Number base of Integer (Fraction) new system Result 0.2345 *2 0 MSB 0.4690 *2 0 0.9380 *2 1 0.8760 *2 1 0.7520 *2 1 0.5040 *2 1 LSB 0.0080 (0.2345)10 = (0.001111)2 Converting Decimal Fraction to Octal Number base of Integer (Fraction) new system Result 0.2345 *8 1 MSB 0.876 *8 7 0.008 *8 0 0.064 *8 0 0.512 *8 4 0.096 *8 0 LSB 0.768 (0.2345)10 = (0.17004)8 Converting Decimal Fraction to Hexadecimal Number base of Integer (Fraction) new system Result 0.2345 *16 3 MSB 0.752 *16 C 0.032 *16 0 0.512 *16 8 0.192 *16 3 0.072 *16 1 0.152 *16 2 LSB 0.432 (0.2345)10 = (0.3C08312)16 Converting Decimal to Binary, Octal, Hexadecimal Example: convert 234.625 to binary , octal ,hexadecimal 234.625 = (11101010.101)2 234.625 = (352.5)8 234.625 = (EA.A)16 Converting Binary to Octal and Hexadecimal Convert the binary number 1110101100110 to Hexadecimal convert to (1110101100110)2 decimal (1110101100110)2 = 212 +211 +210 +28 +26 +25 +22 +21 = 7526 Number base of Reminder convert 7526 to hexadecimal (Quotient) new system 7526 ÷16 6 470 ÷16 6 7526 = (1D66)16 29 ÷16 13 (1110101100110)2= (1D66)16 1 ÷16 1 0 Converting Binary to Octal and Hexadecimal A binary number can be converted into octal or hexadecimal number using a shortcut method. o An octal digit can be represented as a combination of 3 bits, since 23 = 8. o A hexadecimal digit can be represented as a combination of 4 bits, since 24 = 16. Example: Convert the binary number 1110101100110 to hexadecimal and octal Note: The conversion of a number from octal and hexadecimal to binary uses the inverse of the steps defined for the conversion of binary to octal and hexadecimal. Converting Binary to Hexadecimal Example: Convert the binary number 1110101100110 to hexadecimal (1110101100110)2 = 1 - 1101 - 0110 - 0110 =1- D - 6 -6 = (1D66)16 Converting Binary to Octal Example: Convert the binary number 1110101100110 to octal. (1110101100110)2 = 1 - 110 - 101 - 100 - 110 =1 - 6 -5 -4 -6 = (16546)8 Converting Binary to Octal and Hexadecimal Example: Convert the following binary number 1111010010.01001 to Hexadecimal and octal (1111010010.01001)2 = 11 - 1101 - 0010. - 0100 -1000 = 3 - D - 2. - 4 - 8 = (3D2.48)16 (1111010010.01001)2 = 1 - 111 - 010 - 010. - 010 - 010 = 1 - 7 - 2 - 2. - 2 - 2 = (1722.22)8 Converting Hexadecimal and Octal to Binary Example: Convert to binary (1FA.4C)16 = 1 - F - A. - 4 - c = 0001 - 1111 - 1010. - 0100 - 1100 = (000111111010.01001100)2 (456.41)8 = 4 - 5 - 6. - 4 - 1 = 100 - 101 - 110 - 100 - 001 = (100101110.100001)2

Use Quizgecko on...
Browser
Browser