Inner work more / less than

I'm just wondering how the result is more or less than calculated and returned to high-level languages.

I am looking for a hardware gate model here.

Let's use a single example to explain, say 5> 3.

+3
source share
1 answer

Usually it is implemented by subtraction with the detection of transfer.

From the point of view of gating, the subtraction of binary numbers is performed by transmitting matched pairs of bits from each operand through a subtracter:

            +-----+
carry_in -->|     |
            |     |--> a_minus_b
       a -->| SUB |
            |     |--> carry_out
       b -->|     |
            +-----+

a_minus_b = carry_in ⊕ a ⊕ b
carry_out = (carry_in ∧ b) ∨ (¬a ∧ (carry_in ∨ b))

0 a b _ 0. 1 , carry_in carry_out -0 . , , 1, a < b, 0.

, a_minus_b ORed , , , a = b.

, if (a < b) { ... }.

5 > 3 .

+6

Source: https://habr.com/ru/post/1777295/


All Articles