# Integers. Integer Storage Since Binary consists only of 0s and 1s, we cant use a negative sign ( - ) for integers. Instead, the Most Significant Bit is.

## Presentation on theme: "Integers. Integer Storage Since Binary consists only of 0s and 1s, we cant use a negative sign ( - ) for integers. Instead, the Most Significant Bit is."— Presentation transcript:

Integers

Integer Storage Since Binary consists only of 0s and 1s, we cant 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?

Integers 2s Complement Notation

2s Complement Notation (examples in 8 bits to save space) Fixed length notation system. Uses 1 to represent negative values. The largest non-negative value: 01111111 The smallest non-negative value: 00000000 The largest negative value is: 11111111 The smallest negative value is: 10000000

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

2s 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. 2s Complement is a Fixed Length system. There are no signs, so to find a numbers complement, another technique is needed.

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

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

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

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

2s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2s complement notation for -5: Represent +5 in fixed length00000101 flip the bits ( 1 0, 0 1 )

2s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2s complement notation for -5: Represent +5 in fixed length00000101 flip the bits ( 1 0, 0 1 ) 11111010

2s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2s complement notation for -5: Represent +5 in fixed length00000101 flip the bits ( 1 0, 0 1 ) 11111010 add 1 to the new pattern+1

2s Complement Notation One such technique is to simply change each bit to its opposite, and then add 1. To find the 2s complement notation for -5: Represent +5 in fixed length00000101 flip the bits ( 1 0, 0 1 ) 11111010 add 1 to the new pattern+1 to produce -511111011

2s Complement Notation Complementary numbers sum to 0.

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

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

2s Complement Notation 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

Download ppt "Integers. Integer Storage Since Binary consists only of 0s and 1s, we cant use a negative sign ( - ) for integers. Instead, the Most Significant Bit is."

Similar presentations