0

How does this work I am not really sure.

input a, 32 bits:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1

input b, 32 bits:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1

Less Than Result:

32 bit answer:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

The Less Than value is equal to the result of the subtraction in place 31 (because the highest bit of two's complement number is 1 iff the number is negative).

I do not really understand this

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Kombat
0

Think of it this way,
a = 19;
b = 5;
result = a < b; // result = 0

So its essentially the same thing. You compare each bits. Check if
there is a mis-match, and go from there.

For example the equation for A < B, where A is a 2 bit number and
B is a 2 bit number would be this :

Let A = a1 a2;
Let B = b1 b2;

Where a1 and b1 are the left most bit. We are using the complementary
system, so a1 represents '-' if a1 = 1, and b1 represents '-' if b1 = 1.

Below the "!" is the negation operator. Then "+" is the or operator
and "*" is the and operator.

So the boolean equation is [A < B] = ( a1 * !b1) + (!a2 && b2)

Note that the above equation does not handle negative zero.

0

If i calculated my sum as

*sum = ( !a && !b && carry_in) || (!a && b && !carry_in) || (a && !b && !carry_in) || ( a && b && carry_in);

how would I compute less than? do I use the carry's as well? I am only working with one bit at a time

Edited by Kombat: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.