Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.

Similar presentations


Presentation on theme: "Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted."— Presentation transcript:

1 Data Representation in Computers

2 Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted of symbols e.g. Roman number system - I for 1, II for 2, III for 3 etc.  Positional numbering – Symbols represent different values depending on the position they occupy e.g. the Decimal system

3 Data Representation in Computers/Session 3 / 3 of 33 Decimal Number System  365 = (3 * 100) + (6*10) + (5*1)  The value of each digit in the number system is determined by: The digit itself The position of the digit in the number The base/radix of the system Base Position number (6*10)

4 Data Representation in Computers/Session 3 / 4 of 33 Binary Number System  The binary number system has a base of two and symbols used are 0 and 1.  In this number system, as we move to the left, the value of the digit will be two times greater than its predecessor because the base is two.  Thus the value of the places are : 128   64  32  16  8  4  2  1 0001 1110 0101 0111 Most Significant bitLeast Significant bit Binary Number

5 Data Representation in Computers/Session 3 / 5 of 33 Octal number systems Binary Octal 000 0 001 1 010 2 011 3 100 4 101 5 110 6 111 7  Uses a base of 8  Values increase from right to left 1, 8, 64, 512, 4096...  Example: 1204 = (1 * 512) + (2 * 64) + (0 * 8) + (4 * 1) = 512 + 128 + 0 + 4 = 644

6 Data Representation in Computers/Session 3 / 6 of 33 Hexadecimal Number Systems Hexadecimal Decimal 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 A 10 B 11 C 12 D 13 E 14 F 15  Uses a base of 16  The 16 symbols required for the hexadecimal number system obtainedby using the alphabets A, B, C, D, E and F  Example: A0119 = (10 * 65,536)+(0 * 4,096)+(1 * 256)+ ( 1 * 16) + ( 9 * 1) = 6,55,360 + 0 + 256 + 16 + 9 = 6, 55, 641

7 Data Representation in Computers/Session 3 / 7 of 33 Octal  Binary Conversion BinaryOctal 0000 0011 0102 0113 100 4 1015 110 6 111 7  Binary to octal : group 3 bits from right to left  Otal to binary : each digit is represented by 3 bits

8 Data Representation in Computers/Session 3 / 8 of 33  Binary to decimal: …128<64 <32 <16 <8 <4 <2 <1 Or a n a n-1 ….a 2 a 1 a 0 = a n *2 n + a n-1 *2 n-1 +….+a 2 *2 2 +a 1 *2 1 +a 0 *2 0  The decimal equivalent of 110100 is = (1 * 32 ) + (1 * 16) + (0 * 8) + ( 1 * 4) + ( 0 * 2) + (0 * 1) = 32 + 16 + 0 + 4 + 0 + 0 = 52 Binary  Decimal Conversion

9 Data Representation in Computers/Session 3 / 9 of 33  Decimal to Binary: Divide the decimal number by 2 Note the remainder in one column and divide the quotient again with 2 Keep repeating this process until quotient is reduced to a zero Reading remainders in the reverse order gives the binary equivalent Binary  Decimal Conversion

10 Data Representation in Computers/Session 3 / 10 of 33 E.g. Converting the decimal number 52 to its binary equivalent. 52 |_2_ 0 26 | _2_ 0 13 |_2_ 1 6 |_2_ 0 3 |_2_ 1 1 |_2_ 10 Thus the binary equivalent of the decimal number 52 is 11 01 00 Example

11 Data Representation in Computers/Session 3 / 11 of 33 Binary Hexadecimal conversion  Hexa to binary : Each hexadecimal digit is represented by 4 bits Example: 1A412C is represented 0001 1010 0100 0001 0010 1100 Delete digits 0 on the left  110100100000100101100  Binary to hexa: Group 4 digits from right to left Convert groups to 16 base Example: 10101011000010 0010 1010 1100 0010 2 A C 2

12 Data Representation in Computers/Session 3 / 12 of 33 Data Representation  Digital computers use binary code to represent characters.  Binary code is made up of binary digits or bits.  A string of "0s" and "1s" is used to represent characters.  Byte is a sequence of 8 bits.  Most computers have words that consist of 8 or 16 bits.  In large computers the number of bits per word could be 16 or 32 bits.

13 Data Representation in Computers/Session 3 / 13 of 33 Binary Arithmetic Addition The following rules of binary addition are to be remembered: 0 + 0 = 0 0 + 1 = 1 = 1 + 0 1 + 1 = 0 carry 1 to the next column to the left 1 + 1 + 1 = 1 carry 1 to the next column e.g. Carry 1 1 1 1 1 10 11 + 1 11 10 00 10

14 Data Representation in Computers/Session 3 / 14 of 33 Complementary Subtraction n Three steps to perform subtraction :  Find the complement of the number you are subtracting  To the complement of the number add the number we are subtracting from  If there is a carry of 1 add the carry to the result of the addition Else re-complement the sum and attach a negative sign e.g. Number Complement 10 00 11 01 01 11 00 10 00 10 10 10 11 01 01 01

15 Data Representation in Computers/Session 3 / 15 of 33 Example of subtraction : e.g. 1010101 - 1001100 Step 1. Find the complement of 1001100  0110011 Step 2. Do the Add operation carry 11 1 011 1 1 01 01 01 + 0 11 00 11 0 00 10 00 Since there is a carry of 1, Add the carry 0 00 10 00 + 1 0 00 10 01 Complementary Subtraction (Contd.)

16 Data Representation in Computers/Session 3 / 16 of 33 e.g.2 101100 - 11100101 Step 1. Complement of 11100101 is 00011010 Step 2. Carry 01 11 00 10 11 00 +00 01 10 10 01 00 01 10 Step 3. Since there is no carry we re-complement the result and add a negative sign Thus the answer is -10111001 Complementary Subtraction (Contd.)

17 Data Representation in Computers/Session 3 / 17 of 33 Multiplication Rules for Multiplication: 0 x 0 = 0 0 x 1 = 0 1 x 0 = 0 1 x 1 = 1 E.g.. 10101 * 11001 10101 x11001 ------- 10101 00000 10101 ----------- 1000001101

18 Data Representation in Computers/Session 3 / 18 of 33 Division 1. Start from the left of the dividend 2. Perform subtraction i.e. divisor should be subtracted from the dividend a) if subtraction is possible put 1 in the quotient and subtract the divisor from digits of the dividend else put 0 in the quotient b) bring down the next digit to the right of the remainder 3. Do step 2 till no more digits remain in the dividend

19 Data Representation in Computers/Session 3 / 19 of 33 Example The complete table for binary division is: 0/1 = 0 1/1 = 1 E.g 100001 / 110 Then 0101 ( Quotient ) ________ (Divisor) 110 | 1000 01 (Dividend) Quotient -110 101 10 0 10 01 - 1 10 11(Remainder)


Download ppt "Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted."

Similar presentations


Ads by Google