How do computers compare numbers?

486 views

Example: How does a computer know that 8 ist greater than 3?
Because it works in binary, how does it know that 1000 (8) is greater than 0011 (3)?

In: 2

8 Answers

Anonymous 0 Comments

On the CPU, there is a part called a binary comparator.
There are a lot of ways to implement one. But let’s just talk about that 8>3 example in an inefficient but easy way.
You can compare bit by bit. Ignore everything else, 1>0 and 0<1. The most significant bits are more important, so the fact that the 1s and2s place are bigger in 3 doesn’t matter, because the8’s place is 1 in 8 and 0 in 3.
It’s all just a matter of building the circuits so it follows a truth table.
If you want to see the actual lay out, just look up digital comparator.

You are viewing 1 out of 8 answers, click here to view all answers.