Title: Sign Mantissa
1Sign Mantissa
We sacrifice 1 bit (MSB) and use it as a flag to
indicate whether the binary number is - or .
e.g. 100101012 -gt -2110 000101012 -gt
2110
What is the range of values that we can represent
with sign mantissa binary numbers (using 8 bits) ?
Answer -127 . . . 127
2Disadvantages?
Sign bit must be handle differently from the rest
of the binary number during arithmetic operations
100000012 -110 000001012 510
100001102 -610 lt- Wrong!
2 ways of representing the value 0!
000000002 100000002
32s Complement
- The 2s Complement system uses a wrape-arount
binary number system. - 8 bits -gt 256 different values in the range of 0
. . . 255 - To represent negative numbers, we let half of
these numbers be negative, and the other half
positive. - -gt Use Modulo-256 arithmetic
4This is similar to the clock
If we subtract 4 hours from 2 oclock we get
10 oclock, not -2 oclock
The clock uses a modulo-12 numbering system.
5This is similar to the clock
To represent -4 in the modulo-12 system we
subtract 4 from 12 to give 8. Why?
4 8 12 4 -4 0 i.e. 0 - 4 -4
12 - 4 8
In modulo-12 system
6Modulo-256
For modulo-256, (8 bits -gt 28256), to encode a
negative value we subtract the value from 256.
e.g. -4 -gt subtract 4 from 256 252
-4 8 4 -gt 252 8 260
256 4
Note that there is now only 1 way of
representing the value 0.
7Change the sign of 2s complement
- How to change the sign of a number in 2s
comlpement? - 1. Invert all the bits in the original binary
number - 2. Add 1 to the number
- Why?
- Inverting the bits subtracting the number from
255 - But we want to subtract the number from 256
- -gt Add 1 to the result
8Example
01101001 -gt 105 1. Invert 10010110 -gt
150 (255 - 105) 2. Add 1 10010110 00000001
10010111 -gt
-105 if 2s complement 151 if positive
(256-105)
92s Complement Encoded Binary Numbers
- Sign of a 2s complement encoded binary is given
by examing the MSD, just as with sign mantissa
format. - But 2s complement doesnt need any special
arithmetic rules, unlike sign mantissa. - What range of values can be represented with 2s
complement binary numbers (using 8 bits) ? - Answer -128 . . . 127
102s Complement in a Reflective Operation
TC(TC(n)) n -gt -(-(n)) n
000000012 -gt 110 1. Invert 111111102 2.
Add 1 111111112 -gt -110 3.
Invert 000000002 4. Add 1
000000012 -gt 110