1 / 42

19.3 Representation of Numeric Data

19.3 Representation of Numeric Data. Fixed-point Representation. Numbers within computers can be expressed by. Sign-and-magnitude representation Two’s complement representation. Sign-and-magnitude Representation. The most significant bit represents the sign of the number:.

celmore
Download Presentation

19.3 Representation of Numeric 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

Presentation Transcript


  1. 19.3 Representation of Numeric Data

  2. Fixed-point Representation • Numbers within computers can be expressed by • Sign-and-magnitude representation • Two’s complement representation

  3. Sign-and-magnitude Representation • The most significant bit represents the sign of the number: 1 for negative and 0 for positive • The remaining bits represent the magnitude of the number.

  4. Bits for magnitude Sign bit

  5. Binary fraction Sign bit 0 0 0 1 1 1 1 0  Binary Fraction in Sign-and-magnitude Representation = 11.112 = 21 + 20 + 21+ 22 = 2 + 1 + 0.5+ 0.25 = 3.7510

  6. Binary fraction  Sign bit 1 1 0 1 1 1 1 1 = 10111.112 = (24 + 22 + 21+ 20 + 21+ 22) = (16 + 4 + 2 + 1 + 0.5+ 0.25) = 23.7510

  7. Two’s Complement Representation • The most significant bit represents a negative quantity. • The magnitude of the number is the sum of all digit values of the bits.

  8. Most significant bit

  9. With the two’s complement representation, it is easy to change a positive number to the corresponding negative number and vice versa.

  10. The steps are as follows: • Change all 0s to 1s. • Add 1 to the rightmost digit.

  11. Change 2510 to 2510.

  12. Change 2310 to 2310.

  13. Binary fraction  Most significant bit 0 0 1 0 1 1 1 0 Binary Fraction in Two’s Complement Representation = 101.1102 = 22 + 20 + 21+ 22 = 5.7510

  14. Binary fraction  Most significant bit 1 0 0 1 0 0 1 1 = 1001.00112 = 23 + 20 + 23+ 24 = 6.812510

  15. 61 00111101 61 +) –74 +) 10110110 –) 74 –13 11110011 –13 Addition and Subtraction in Two’s Complement Representation = 13(valid) • Subtraction can be done by complementation and addition.

  16. 61 +) 74 135 00111101 +) 01001010 10000111 = 121 (invalid) • The result is invalid because of an overflow error.

  17. 11000011 –61 +) 10110110 +) –74 1 01111001 –135 The extra bit is discarded because this is an 8-bit code. = 121 (invalid) • The result is invalid because of an overflow error.

  18. 11000011 –61 –61 +) 01001010 –) –74 +) 74 1 00001101 13 13 The extra bit is discarded because this is an 8-bit code. = 13(valid)

  19. Comparisons between Sign-and-magnitude and Two’s Complement Representation

  20. Floating-point Representation • A number is composed of a fraction part called a mantissa and a power called an exponent. • It represents numbers in a wider range.

  21. Sign of mantissa Sign of exponent Exponent Mantissa 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0  • Bit 0 to bit 7 represent the exponent and bit 8 to bit 15 represent the mantissa.

  22. Normalisation • A standardised floating point representation. • The first bit of the mantissa must be non-zero.

  23. 0 1 1 1 0 1 0 0 0 0 0 0 0 0 1 1 Mantissa Exponent • For example, 7.2510 = 111.012 20 = 0.111012 23

  24. Example 19.17 Express 1001.0112 in floating-point representation.

  25. 0 1 0 0 1 0 1 1 0 0 0 0 0 1 0 0 Solution 1001.0112 = 0.10010112 24  The floating-point representation is:

  26. Example 19.18 Express 0.0000011112 in floating-point representation.

  27. 0 1 1 1 1 0 0 0 1 0 0 0 0 1 0 1 Solution 0.0000011112 = 0.11112 25  The floating-point representation is:

  28. Example 19.19 Convert 1110000100000110, which is in floating-point representation, into a decimal value.

  29. Solution 1110000100000110 = 0.11000012 26 = 0110000.12 = 48.510

  30. Comparisons between Fixed-point and Floating-point Representation

  31. Truncation Errors • It means dropping off any extra digits which cannot be accommodate.

  32. Example 19.20 Truncate 123.88 to 4 significant figures.

  33. 123.8 Solution 123.88 This causes a truncation error. The error is 123.88  123.8 = 0.08

  34. 0.1010102 Example 19.21 Truncate 0.10101012 to 6 bits. Solution 0.10101012

  35. Rounding Errors • It means shortening a number by deleting one or more digits in the least significant positions.

  36. Increasing by one the remaining far right digit if the truncated digit is greater than or equal to half of the number base.

  37. Example 19.22 Round 123.88 to 4 significant figures.

  38. 123.9 Solution 123.88 This causes a rounding error. The error is 123.9  123.88 = 0.02

  39. 0.1010112 Example 19.23 Round 0.10101012 to 6 bits. Solution 0.10101012

  40. Overflow and Underflow Errors • Since the fixed-point and floating- point representations of a number have their own ranges, this causes • An overflow error if the number exceeds the range that can be represented.

  41. An underflow error if the number is too small to be represented.

More Related