EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
1 number systems-unsignedsignedintegers
1. Unsigned Integers
• Represents positive integers only
• Example: ASCII character codes
• Not necessary to indicate a sign, so all 8 or 16 bits can be
used for the magnitude:
– 1 byte = 8 bits = 28 = 256 (0 to 255)
– 2 bytes = 16 bits = 216 = 65,536 (0 to 65,535)
– 4 bytes = 32 bits = 232
= 4,294,967,296 (0 to 4,294,967,295)
2. Signed Integers
Represents positive and negative integers
… -2, -1, 0, 1, 2, …
MSB (Most Significant Bit – leftmost bit) used to indicate
sign
0 = positive, 1 = negative
One less bit is used for the magnitude, with one extra
negative value
1 byte = 8-1 bits = 27 (-128 to +127)
2 bytes = 16-1 bits = 215 (-32,768 to +32,767)
4 bytes = 32-1 bits = 231 (-2,147,483,648 to
+2,147,483,647 )
3. Signed Integers
Let consider the binary:
I I 0 0 0 I I 0
Convert it to decimal number.
Use positional representation as shown previously with one change in
the MSB
-27 * 1 = -128
26 * 1 = 64
25 * 0 = 0
24 * 0 = 0
23 * 0 = 0
22 * 1 = 4
21 * 1 = 2
20 * 0 = 0
-128 +(64+4+2)=58
4. Signed Integers
Some values of interest (8-bit example):
• +0
0 0 0 0 0 0 0 0
• +1
0 0 0 0 0 0 0 I
• -1
I 0 0 0 0 0 0 0
I I I I I I I I
5. Signed Integers
Some values of interest (8-bit example):
• Max positive value
0 I I I I I I I = 127
• Most negative value
I 0 0 0 0 0 0 0 = -128
6. 1’s & 2’s Complement
• 1’s complement form
– Formed by reversing (complementing) each bit
• 2’s complement form
– Formed by adding 1 to 1's complement
– Negative numbers are stored this way
• Additive inverse of a number
• Computer never has to subtract
• A – B = A + (-B)
8. Class Exercise
• Convert the following negative decimal
numbers to 8 bit binary using the 2’s
complement
– -1, -3, -8, -17
9. Class Exercise
• Evaluate 25 + (- 5) in 8 bit binary
– Convert 25 to binary
– Convert -5 to 2’s complement
– Add together
– Check your answer by converting back to decimal