1 / 23

Integers

Integers. Integer Storage. Since Binary consists only of 0s and 1s, we can’t use a negative sign ( - ) for integers. Instead, the M ost S ignificant B it is used to represent the sign. This way, half the combinations in a fixed length of bits can be used to represent negative values.

minor
Télécharger la présentation

Integers

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. Integers

  2. Integer Storage Since Binary consists only of 0s and 1s, we can’t use a negative sign ( - ) for integers. Instead, the Most Significant Bit is used to represent the sign. This way, half the combinations in a fixed length of bits can be used to represent negative values. But which value of the sign bit (0 or 1) will represent a negative number?

  3. Integers 2’s Complement Notation

  4. 2’s Complement Notation(examples in 8 bits to save space) • Fixed length notation system. • Uses 1 to represent negative values. Since 1 is always greater than 0, • the largest non-negative value: 01111111 • the smallest non-negative value: 00000000 • the largest negative value: 11111111 • the smallest negative value: 10000000

  5. 2’s Complement Notation(examples in 8 bits to save space) What is the decimal equivalent of these? • The largest non-negative value: 01111111 • The smallest non-negative value: 00000000 • The largest negative value: 11111111 • The smallest negative value: 10000000

  6. 2’s Complement Notation(examples in 8 bits to save space) What is the decimal equivalent of these? • The largest non-negative value: 01111111 +127 • The smallest non-negative value: 00000000 • The largest negative value: 11111111 • The smallest negative value: 10000000

  7. 2’s Complement Notation(examples in 8 bits to save space) What is the decimal equivalent of these? • The largest non-negative value: 01111111 +127 • The smallest non-negative value: 00000000 +0 • The largest negative value: 11111111 • The smallest negative value: 10000000

  8. 2’s Complement Notation(examples in 8 bits to save space) What is the decimal equivalent of these? • The largest non-negative value: 01111111 +127 • The smallest non-negative value: 00000000 +0 • The largest negative value: 11111111 -1 • The smallest negative value: 10000000

  9. 2’s Complement Notation(examples in 8 bits to save space) What is the decimal equivalent of these? • The largest non-negative value: 01111111 +127 • The smallest non-negative value: 00000000 +0 • The largest negative value: 11111111 -1 • The smallest negative value: 10000000 -128

  10. 2’s Complement Notation The representations of non-negative integers in 2’s Complement look the same as they do for Natural numbers. However, negative values look VERY different than we might expect.

  11. 2’s Complement Notation • Complementary numbers sum to 0. • Decimal is a Signed Magnitude system so complements have the same magnitude but different signs: 5 and -5, for example. • 2’s Complement is a Fixed Length system. There are no signs, so to find a number’s complement, another technique is needed.

  12. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1.

  13. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  14. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  15. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  16. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  17. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  18. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  19. 2’s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:

  20. Complementary numbers sum to 0. 2’s Complement Notation

  21. Complementary numbers sum to 0. So if to +5 00000101 2’s Complement Notation

  22. Complementary numbers sum to 0. So if to +5 we add -5 00000101 +11111011 2’s Complement Notation

  23. Complementary numbers sum to 0. So if to +5 we add -5 we should get 00000101 +11111011 1 00000000 discard the carry bit to retain the fixed length 2’s Complement Notation

More Related