One's and Twos
One's and Twos
One's and Twos
Compliments
Horners Method
Suppose we wish to compute the value of the hexadecimal
number 2CD5. we can multiply each digit by its weight,
and add up all the products.
2 x 16 + 12 x 16 + 13 x 16 + 5
A straightforward, but inefficient, way to evaluate the
above expression is to:
1.
2.
3.
Multiply 13 by 16
4.
Horners Method
1.
We start with the most significant digit, multiply by 16 and then add the
next digit.
2.
3.
We continue in this fashion until we reach the point where we add the least
significant digit.
16
32
product
12
44
x
16
multiply result by 16
704
+
13
717
x
16
multiply result by 16
11472
+
5
11477
sign bit
0000000000000101 = +5
magnitude
The
The
1 add 1
Twos
complement representation is
another representation that can
accommodate both positive and
negative numbers.
The advantage of twos complement
representation is that unlike signmagnitude representation, it does not
require a computer to perform sign
analysis when adding or subtracting.
To
For
Clearly,
1111111111111010 = +5 flipped
+
1
1111111111111011 = +5 flipped + 1
Now
carry
0000000000000101 = +5
+ 1111111111111011 = +5 flipped + 1
0000000000000000
Indeed,
When
Thus
In
Although
Furthermore,
Computer
That
For
0000000011111110 is
1111111100000001
If we add a number and its ones complement, we get a sum in
which all the bits are one.
0000000011111110
+ 1111111100000001
1111111111111111
Adding a number with its ones complement does not
yield zero. Thus, we conclude that the ones
complement of a number is not the negative of that
number.
But suppose we let the value zero be represented by two bit patterns: all zeros
and all ones. Then adding a number wit its ones complement would, indeed
yield zero.
For addition, we must add the end-around carry to the LSB of the sum
ex. Add -1 with -1
carry out
intermediate sum
end-around carry
Ones
Negation
Ones
First,
If
Second,
Excess-n representation
In
Thus,
To obtain
An
Excess-4
Twos
complement
000
100
001
101
010
110
011
111
100
000
101
001
110
010
111
011