How do computers compare numbers?

493 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

Effectively, if you’re checking of A>B, the computer will do A-B, and throw away the result. What it cares about are the *registers* after the operation.t

Registers are essentially flags that get set after every instruction, and they can be used by subsequent instructions. For example, one of those registers will be the Zero register. That is set if the final result is exactly 0. Another one will be the Sign register, which is set if the result is negative.

Those registers are all done via the actual circuitry in the CPU using logical AND, OR, XOR, and NOT gates. They’re effectively created as a side effect of the calculation the CPU is doing.

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