Code-hidden in the language behind the computer-reading notes (V): binary addition & Subtraction

Source: Internet
Author: User

12. Binary adder

1) If you want to build a computer, then the first thing you can calculate the sum of two number of devices (in fact, the original addition calculation is the only work the computer to do).

2) adder = wire + switch + bulb + battery + relay (fully used in binary calculation)

3) Addition and carry in the adder is separate, the result of the addition of the two binary numbers is by the XOR gate (XOR gate xor:1 and 0 does not appear at the same time is 1; otherwise 0) the output is given, and the carry bit is given by the output of the gate.

4) Full/half adder: The half adder does not include the previously added possible carry bit into the next operation

5) Reform: relays--Vacuum tubes---> transistors (smaller transistors, less noise, lower energy consumption, cheaper)

13. How to Implement Subtraction

1) addition is always calculated from the leftmost column of the two addend to the leftmost column, and the carry of each column is added to the next column. There is no rounding in the subtraction, only borrow. But borrow's implementation is complicated, so here's a little trick to avoid borrow.

When the meiosis is greater than the meiosis, (253-176), the 999-176+253+1-1000 is used first.

When the meiosis is greater than minuend, it is negative (176-253), 999-(999-253+176)

2) Sub and Co signal control overflow underflow

3) Negative number: 10 of the complement, 1 is the beginning of the expression is negative-128 to 127

Code-hidden in the language behind the computer-reading notes (V): binary addition & Subtraction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.