ict lec 4.pptx
Document Details
Uploaded by ValiantCthulhu
COMSATS University Islamabad
Tags
Full Transcript
Introduction to Information and Communication Technologies Lecture # 4 Zaheer A. Gondal Department of Computer Science CUI Lahore Campus [email protected] The slides are adapted...
Introduction to Information and Communication Technologies Lecture # 4 Zaheer A. Gondal Department of Computer Science CUI Lahore Campus [email protected] The slides are adapted from the publisher’s material Understanding Computers: Today and Tomorrow (Ch2) & Computer Science Illuminated (Chapter 2) Data and Program Representation In order to be understood by a computer, data and programs need to be represented appropriately Coding systems: Used to represent data and programs in a manner understood by the computer Digital computers: Can only understand two states, off and on (0 and 1) Digital data representation: The process of representing data in digital form so it can be understood by a computer 2 Digital Data Representation Bit: The smallest unit of data that a binary computer can recognize (a single 1 or 0) Byte = 8 bits Byte terminology used to express the size of documents and other files, programs, etc. Prefixes are often used to express larger quantities of bytes: kilobyte (KB), megabyte (MB), gigabyte (GB), terabyte (TB), etc. 3 The Binary Numbering System Numbering system: A way of representing numbers Decimal numbering system Uses 10 symbols (0-9) Binary numbering system Uses only two symbols (1 and 0) to represent all possible numbers In both systems, the position of the digits determines the power to which the base number (such as 10 or 2) is raised 4 The Binary Numbering System 5 Coding Systems for Text-Based Data ASCII and EBCDIC ASCII (American Standard Code for Information Interchange): coding system traditionally used with personal computers EBCDIC (Extended Binary- Coded Decimal Interchange Code): developed by IBM, primarily for mainframe use 6 Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers A value less than 0, with a – sign Examples: -24, -1, -45645, -32 7 Numbers Integers A natural number, a negative number Examples: 249, 0, - 45645, - 32 Rational Numbers An integer or the quotient of two integers Examples: -249, -1, 0, 3/7, -2/5 8 Positional Notation 642 is 600 + 40 + 2 in BASE 10 The base of a number determines the number of different digit symbols (numerals) and the values of digit positions 9 Positional Notation Continuing with our example… 642 in base 10 positional notation is: 6 x 102 = 6 x 100 = 600 + 4 x 101 = 4 x 10 = 40 + 2 x 10º = 2 x 1 = 2 = 642 in base 10 The power indicates the position of the number This number is in base 10 10 Positional Notation As a formula: R is the base of the number dn * Rn-1 + dn-1 * Rn-2 +... + d2 * R1 + d1 * R0 n is the number of d is the digit in the digits in the number ith position in the number 642 is 6 * 102 + 4 * 10 + 2 * 1 11 Positional Notation What if 642 has the base of 13? + 6 x 132 = 6 x 169 = 1014 + 4 x 131 = 4 x 13 = 52 + 2 x 13º = 2x1 = 2 = 1068 in base 10 642 in base 13 is equivalent to 1068 in base 10 Binary Decimal is base 10 and has 10-digit symbols: 0,1,2,3,4,5,6,7,8,9 Binary is base 2 and has 2-digit symbols: 0,1 For a number to exist in a given base, it can only contain the digits in that base, which range from 0 up to (but not including) the base. What bases can these numbers be in? 122, 198, 178, G1A4 Converting Binary to Decimal What is the decimal equivalent of the binary number 1101110? 1 x 26 = 1 x 64 = 64 + 1 x 25 = 1 x 32 = 32 + 0 x 24 = 0 x 16 = 0 + 1 x 23 = 1 x 8 = 8 + 1 x 22 = 1 x 4 = 4 + 1 x 21 = 1 x 2 = 2 + 0 x 2º = 0 x 1 = 0 = 110 in base 10 Converting Binary to Decimal (Float) What is the decimal equivalent of the binary number 10101.011? Converting Decimal to Binary What is the Binary equivalent of the decimal number 75? 2 75 2 37 1 2 18 1 75 = 1001011 2 9 0 2 4 1 2 2 0 1 0 Converting Decimal to Binary (Float) What is the Binary equivalent of the decimal number 75.40? 2 75 75 = 1001011 =0.40 x 2 = 0.8 =0.80 x 2 = 1.6 2 37 1 =0.60 x 2 = 1.2 =0.20 x 2 = 0.4 2 18 1 0.40 = 0110 Pick the Integer Part until 2 9 0 term become 0 or for at least 4 terms 2 4 1 75.40 = (1001011.0110) 2 2 0 1 0 Octal number system Base 8 has 8 digits: 0,1,2,3,4,5,6,7 Converting Octal to Decimal What is the decimal equivalent of the octal number 642? 6 x 82 = 6 x 64 = 384 + 4 x 81 = 4 x 8 = 32 + 2 x 8º = 2 x 1 = 2 = 418 in base 10 Converting Binary to Octal (direct) Mark groups of three (from right) Convert each group 10101011 10 101 011 2 5 3 10101011 is 253 in base 8 Bases Higher Than 10 How are digits in bases higher than 10 represented? With distinct symbols for 10 and above. Base 16 has 16 digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F Converting Hexadecimal to Decimal What is the decimal equivalent of the hexadecimal number DEF? D x 162 = 13 x 256 = 3328 + E x 161 = 14 x 16 = 224 + F x 16º = 15 x 1 = 15 = 3567 in base 10 Remember, the digit symbols in base 16 are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Converting Binary to Hexadecimal Mark groups of four (from right) Convert each group 10101011 1010 1011 A B 10101011 is AB in base 16 More Conversions Algorithm for converting number in base 10 to other bases While (the quotient is not zero) Divide the decimal number by the new base Make the remainder the next digit to the left in the answer Replace the original decimal number with the quotient Just like decimal to binary conversion More Conversions Decimal to Hexadecimal Decimal to Octal Hexadecimal to Octal Octal to Hexadecimal Hexadecimal to Binary (direct/indirect) Binary to Hexadecimal (direct/indirect) Octal to Binary (direct/indirect) Binary to Octal (direct/indirect) HW: Practice examples of above scenarios