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

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.