BINARY TOPIC 02 – NEGATIVE NUMBERS LESSON WORK SOLUTIONS TASK 1A –
SIGNED MAGNITUDE We
know the number is negative because the first bit is 1. So we need to convert the rest.
8
+ 2 = 10 So,
we know that 00010102 = 1010 And
now we consider the negative, so the answer is -10. B) Convert 0010 1000
(signed magnitude) to base 10. So
this number is positive since the left most bit is 0. We simply convert the rest.
So
the final answer is 32 + 8 = 40. C) Convert 1100 0001
(signed magnitude) to base 10. So
the left most bit tells us it's a negative number. We convert the rest.
That
gives us 64 + 1 = 65. So the final
answer is -65.
TASK 1B So
we know that the left most bit is a 0 since our number is positive. Also, we will assume that we are still
working with a byte for binary.
So,
adding the left most zero, our final answer is 0001 0001. B) Convert -17 to Signed
Magnitude binary. Since
we are dealing with the negative value from A, we simply have to change the
leftmost bit to 1. So
our final answer is 1001 0001. C) Convert -100 to
Signed Magnitude binary. So
the leftmost bit will be a 1. We
convert the rest.
Our
final answer, after adding the left 1, is 1110 0100.
Solution:
1010 0001 Of
course, one can argue that it would be best to add one (or more) bit(s) to
the left in order to include a sign bit.
But we won't worry about that here (at least not until C). B) Convert
0110 0110 from unsigned binary to
signed binary.
Solution:
1110 0110 C) Convert
1011 0111 from unsigned binary to
signed binary. This
time, the leftmost bit is used to specify magnitude. So we cannot use it for sign. So we have to add a bit. Solution:
1 1110 0110 Or
perhaps if we want to keep using bytes and multiples of bytes, our solution
could look like this instead: Solution
2: 1000 0000 1110 0110 Both
solutions above are fine. TASK 2A Solution:
1010 0101 B) Give the One's
Complement of 0110 1100.
Solution
#1:
Solution
#2: Perhaps
we want to keep in our size as multiples of bytes. So,
0000 0000 1001 1001 would become 1111 1111 0110 0110. Note:
You will not get a question like this on the quiz.
So,
17 is 1 0001. We want it to be one byte
in size, so its 0001 0001 (by simply adding zeros on the left). We
don't invert the bits since the number is positive. Solution:
0001 0001 B) Convert -17 from base
10 to one's complement binary. From
A), we know that 17 is 0001 0001. We
now simply invert all the bits. Solution:
1110 1110 C) Convert 17 from base
10 to one's complement binary.
So
11310 is equal to 111 00012. We want to work with a byte, so we tack on
a zero on the left. So, we are at 0111
0001. Now,
we simply invert all bits. Solution:
1000 1110
A) Convert 0110 from
one's complement binary to base 10.
So,
the answer is simply 4 + 2. Solution:
6
Result
of inversion: 0101 Now
we convert to decimal.
Solution:
-5 C) Convert
0101 from one's complement binary to base 10.
Solution:
5 TASK 3A
Solution:
0010 1011
So
43 in binary is 0010 1011 (from part
A) Now
we take the one's complement to get 1101 0100.
Solution:
1101 0101
So,
104 in binary is 0110 1000. Now
we take the one's complement: 1001 0111. And
we add 1. Solution:
1001 1000
We
start off by removing 1 to get 1001 1000. Then
we invert all the bits to get 0110 0111. Now
we convert that to decimal:
Of
course, that is negative. Solution:
-103 We
start off by removing 1 to get 1100 0101. Now
we invert bits to get: 0011 1010. Now
we convert to base 10.
Of
course, it's a negative value. Solution:
-58
Solution:
91 TASK 4A
-128 0000 0000 -127 0000 0001 . . . And
so on… But
that would get pretty long. So
let's consider the counting table with an extra column that simply states the
usual value for that binary number. NUMBER OFFSET BINARY USUAL VALUE -128 0000 0000 0 -127 0000 0001 1 . . . 10 ???? ???? 138 So,
from the table above, we can tell that usual value is 128 higher than the
number. (That's the offset value.) So,
the offset binary for 10 with be the usual value for 138. So we can simply convert 138 to binary and
that will be our answer.
So,
138 is usually 1000 1010. However,
that is the binary offset for our value 10. Solution:
1000 1010.
So
we have the same offset as in B which means that we add 128 to 53 giving us
181. Now
we simply convert 181 to binary like normally to get our answer. Using
the chart, we can figure out that 181 is 128 + 32 + 16 + 4 + 1.
Solution:
1011 0101
-128 0000 0000 Solution:
-126
So
the value is 64+8+1 = 73. Now
the value 73 is actually 128 higher that the answer. So, 73 – 128 gives us -55. C) Convert 1100 1011
from offset binary form (starting point -128) to decimal.
Now
we remove the offset so we do 203 – 128 to get 75. Solution:
75
So,
we get the value 64 + -32 + 4 + -2 + 1 giving us 37. Solution:
37 Right
to the chart.
So,
we get the value -128 + -32 + 16 + 4 giving us -140.
Solution:
85 TASK 5B Let's consider an empty chart.
This
is pretty tough. I know that if we consider only positive numbers under 45,
we won't get enough. So we need to
start with 64.
Now
we are at 64. We have to remove 19 to
get to 45. To do that, the only way is
to include a -32. Otherwise, the best
I would be able to remove is -10 (from -8 and -2). So
we put a 1 over -32.
Now
we are at 32. We need to go up by 13
to get to 45. We must include 16
because if we didn't we couldn't get anything to add up to 13.
So
now we have 48. We need to go down by
3. To do that, we need to remove 8. So
we put a 1 over the -8.
We
are now at 40. We need to add 5. We can do that by placing a 1 over the 4
and the 1.
So
the final answer is 0111 1101. Solution:
0111 1101 B) Convert -101 from
base 10 to base -2. Let's
start with the chart.
I'm
thinking I will start with -128.
So
we are at -128. We need to go up by
27. So we have to include 64 (cause
the other positive numbers don't add up to 27.)
So
we are at -64. We need to add
-37. To do that, we need to include
-32.
We
are now at -96. We need to add
-5. This
gets tough here. If we include 16,
we'd be over by 11 and there would be no way of adding up to -11. So 0 over 16.
We
are still at -96 and need to add -5.
This can get tricky. But after
a bit of playing around, we can see that adding up the remaining four values
(-8 + 4 + -2 + 1) gives us -5.
Solution:
1110 1111 C) Convert -59 from base
10 to base -2. These
feel a little like puzzles. Let's
start with the chart.
So
if we add up -32 and -8 and -2, we only get -40. That's not enough. So we need to start with -128.
We
are at -128 now. We need to go up by
69. So that's pretty easy as that is
64 + 4 + 1. Hurray!
Solution:
1100 0101
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|