1 / 25

260 likes | 404 Vues

Representation of Data. Ma King Man. Reference. Text Book: Volume 2 Notes: Chapter 19. 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

Télécharger la présentation
## Representation of Data

**An Image/Link below is provided (as is) to download presentation**
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.
Content is provided to you AS IS for your information and personal use only.
Download presentation by click this link.
While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

**Representation of Data**Ma King Man**Reference**• Text Book: Volume 2 • Notes: Chapter 19**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**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**Base Conversion between binary, octal and hexadecimal system**• Method • 3 binary digits = 1 octal digit • 4 binary digits = 1 hexadecimal digit**Example 1**• 1110101(ii) • =111 0101(ii) • =75(16)**Example 2**• 1110101(ii) • = 1 110 101(ii) • = 165(8)**Example 3**• 1A46(16) • = 1 1010 0100 0110(ii)**Example 4**• 732(8) • = 111 011 010(ii)**Base conversion from any base to decimal**• Method: • dndn-1dn-2……d1d0d-1d-2……d-m+1d-m • dnbn+dn-1bn-1+……+d1b+d0+d-1b-1+……+d-mb-m(10)**Examples**• E.g.1 • 1101.11(ii) • = 1x23 + 1x22 + 0x21 + 1x20 + 1x2-1 + 1x2-2 • = 13.75 • E.g.2 • 1234.56(8) • = 1x83 + 2x82 + 3x81 + 4x80 + 5x8-1 + 6x8-2 • = 668.71875 • E.g.3 • 11.8(16) • = 1x161 + 1x160 + 8x16-1 • = 17.5**Base conversion from decimal to any base**Step 1: Convert the integral part: 234 = 11101010(ii) Step 2: Convert the fraction part 0.25 = 0.01(ii) Step 3: Therefore, 234.25 = 11101010.01(ii)**Lets Try……**• E.g.2 • 23.0625 • = 27.04(8) • E.g.3 • 13.125 • = 1101.001(ii)**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**The fixed point representation has the following format:**Sign bit**3 methods of fixed-point representation**• Sign-and-magnitude representation • One’s complement representation (optional) • Two’s complement representation**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.**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**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.**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**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**Example 3**E.g. 17 – 23 = 10001 – 10111 = 10001 + (-10111) = 00010001 + 11101001 = 11111010 = -110(ii) = -6**Special cases**Overflow Error Carry discard Overflow Error

More Related