>
> Professor Wolff,
>
> I have a few questions on the homework solutions.
> In question 4, a>=b was done in two parts: take the NOT of the sign bit
> of a-b OR if A=B. Won't the NOT of the sign bit of a-b be 1 if a==b
> making the second a=b redundant?
You are correct for 2's complement representation!
a | b | a-b | sign(a-b) | !sign(a-b)| sign(b-a)| !sign(b-a)
--+---+-----+-----------+-----------+----------+-----------
5 | 3 | 2 | 0 | 1 | 1 | 0
3 | 3 | 0 | 0 | 1 | 0 | 1
3 | 5 | -2 | 1 | 0 | 0 | 1
| | | if (a**=b) | if (b=a)
| | | if (b>a) | if (b<=a) | if (a>b) | if (a<=b)
What about 1's complementation representation??? possible extra credit
question!
> Likewise, if we wanted just a>b, can't we just take the sign bit of b-a?
correct!
> I don't understand the need for two stages in a comparator function.
>Also, for IF(a), is NOT(a==0) box really necessary?
The C language hides the implied comparison in order to write less code,
which to the minimalist programmer is desirable.
> Isn't this just another way of writing IF(NOT(a==0))
> which can be simplified to IF(a)? The box I just used was an IF box.
The IF box you propose is exactly the logic function NOT(a==0) or !(a==0).
Somewhere there has to be hardware has to do it.
--Prof. Wolff.
**