Presentation is loading. Please wait.

Presentation is loading. Please wait.

Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.

Similar presentations


Presentation on theme: "Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19."— Presentation transcript:

1 Representation of Data Ma King Man

2 Reference Text Book: Volume 2 Notes: Chapter 19

3 Road Map Number System Base Conversion between binary, octal and hexadecimal system Base conversion from any base to decimal Base concersion from decimal to any base Fixed - point representation Floating - point number representation Comparison between fixed - point representation and floating point representation

4 Lets start

5 Number System Denary base 0,1,2,3,4,5,6,7,8,9 Binary base 0,1 Octal base 0,1,2,3,4,5,6,7 Hexadecimal base 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

6 Compare… 000000 100111 201022 301133 410044 510155 611066 711177 81000108 91001119 10101012A 11101113B 12110014C 13110115D 14111016E 15111117F

7 Base Conversion between binary, octal and hexadecimal system Method 3 binary digits = 1 octal digit 4 binary digits = 1 hexadecimal digit

8 Example 1 1110101 (ii) =111 0101 (ii) =75 (16)

9 Example 2 1110101 (ii) = 1 110 101 (ii) = 165 (8)

10 Example 3 1A46 (16) = 1 1010 0100 0110 (ii)

11 Example 4 732 (8) = 111 011 010 (ii)

12 Base conversion from any base to decimal Method: d n d n-1 d n-2 …… d 1 d 0 d -1 d -2 …… d -m+1 d -m d n b n +d n-1 b n-1 + …… +d 1 b+d 0 +d -1 b -1 + …… +d -m b -m(10)

13 Examples E.g.11101.11(ii) =1x2 3 + 1x2 2 + 0x2 1 + 1x2 0 + 1x2 -1 + 1x2 -2 =13.75 E.g.21234.56(8) =1x8 3 + 2x8 2 + 3x8 1 + 4x8 0 + 5x8 -1 + 6x8 -2 =668.71875 E.g.311.8(16) =1x16 1 + 1x16 0 + 8x16 -1 =17.5

14 Base conversion from decimal to any base 2234 2117 ……….0 258 ……….1 229 ……….0 214 ……….1 27 ……….0 23 ……….1 1 Step 1: Convert the integral part: 234 = 11101010(ii) Step 2: Convert the fraction part 0.25 = 0.01(ii).25 x 2 0.50 x 2 1.00 Step 3: Therefore, 234.25 = 11101010.01(ii)

15 Lets Try…… E.g.223.0625 = 27.04(8) = 27.04(8)E.g.313.125 = 1101.001(ii) = 1101.001(ii)

16 Fixed – point representation Usually the point is fixed at the right to the L.S.B. – Least significant bit – i.e. integer. Assume 8 – bit word storage is used (8 – bit per unit) Bit 7 is the sign bit of the number “ 0 ” = positive “ 1 ” = negative

17 The fixed point representation has the following format: 76543210 Sign bit

18 3 methods of fixed-point representation Sign-and-magnitude representation One ’ s complement representation (optional) Two ’ s complement representation

19 Sign-and-magnitude (i) The leftmost bit indicates the sign. (ii) The remaining bits give the magnitude of the number. E.g.+10101(ii) is stored as 00010101 (+21 in dec.) And - 10101(ii) is stored as 10010101 (-21 in dec.) Range:For 8 – bit word: The smallest number is 11111111 (-127) The largest number is 011111111 (+127) Disadvantages: 2 representations for zero: 00000000, 10000000 Requires extra circuit to perform addition and subtraction.

20 One’s complement representation (i) Add zeros to the left of the binary numbers until the number is fitted the given length. (ii) For a positive integer, the binary pattern is left unchanged. (iii) For a negative integer, 0 is replaced by 1 and 1 by 0. E.g.+10101(ii) is stored as 00010101 And- 10101(ii) is stored as 11101010 Range:For 8 – bit word: The smallest number is 10000000 (- 127) The largest number is 01111111 (+127) Disadvantages: Same as sign-and-magnitude representation Zero: 00000000, 11111111

21 Two’s complement representation (Most commonly used) (i) and (ii) are same as 1 ’ s complement method. For a negative integer, add 1 to the rightmost bit of it ’ s 1 ’ s complement. E.g.+10101(ii) is stored as 00010101 And – 10101(ii) is stored as 11101011 Range: For 8 – bit word: The smallest number is 10000000 (-128) The largest number is 01111111 (+127) Advantages: It has wider range than both sign-and-magnitude and 1 ’ s complement, and no ambiguity for zero. Subtraction can be done by addition, no extra circuit is required.

22 Example 1 Assume 8 – bit word and 2 ’ s complement notation is used. E.g.23 + 17 =10111 + 10001(binary no.) =00010111 + 00010001(internal representation) =00101000(internal representation) =+ 101000(binary no.) =40 00010111 +00010001 00101000

23 Example 2 E.g.23 – 17 =10111 – 10001(binary no.) =10111 + (-10001)(internal representation) =00010111 + 11101111(internal representation) =00000110(internal representation) =110 (ii) (binary no.) =+ 6 00010111 + 11101111 00000110

24 Example 3 E.g. 17 – 23 =10001 – 10111 =10001 + (-10111) =00010001 + 11101001 =11111010 =-110 (ii) =-6 00010001 + 11101001 11111010

25 Special cases 11101011 (-21) + 10110101 (-75) 1 10100000 (-96) 10001011 (-117) + 10101101 (-83) 1 00111000 (+56) 01110101 (+117) + 00101100 (+44) 1 10100001 (-95) Carry discard Overflow Error


Download ppt "Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19."

Similar presentations


Ads by Google