Back to 课程

Computer-Science-A-level-Ocr

0% Complete
0/0 Steps
  1. 3-3-networks
    8 主题
  2. 3-2-databases
    7 主题
  3. 3-1-compression-encryption-and-hashing
    4 主题
  4. 2-5-object-oriented-languages
    7 主题
  5. 2-4-types-of-programming-language
    4 主题
  6. 2-3-software-development
    5 主题
  7. 2-2-applications-generation
    6 主题
  8. 2-1-systems-software
    8 主题
  9. 1-3-input-output-and-storage
    2 主题
  10. 1-2-types-of-processor
    3 主题
  11. 1-1-structure-and-function-of-the-processor
    1 主题
  12. structuring-your-responses
    3 主题
  13. the-exam-papers
    2 主题
  14. 8-2-algorithms-for-the-main-data-structures
    4 主题
  15. 8-1-algorithms
    10 主题
  16. 7-2-computational-methods
    11 主题
  17. 7-1-programming-techniques
    14 主题
  18. 6-5-thinking-concurrently
    2 主题
  19. 6-4-thinking-logically
    2 主题
  20. 6-3-thinking-procedurally
    3 主题
  21. 6-2-thinking-ahead
    1 主题
  22. 6-1-thinking-abstractly
    3 主题
  23. 5-2-moral-and-ethical-issues
    9 主题
  24. 5-1-computing-related-legislation
    4 主题
  25. 4-3-boolean-algebra
    5 主题
  26. 4-2-data-structures
    10 主题
  27. 4-1-data-types
    9 主题
  28. 3-4-web-technologies
    16 主题
课 Progress
0% Complete

Binary Addition

What is binary addition?

  • Binary addition involves summing numbers in base-2, which uses only the digits 0 and 1

  • Like denary addition, start from the rightmost digit and move towards the left

  • Carrying over occurs when the sum of a column is greater than 1, passing the excess to the next left column

Example addition

binary-addition

Binary addition example

Overflow errors

  • Overflow occurs when the sum of two binary numbers exceeds the given number of bits

  • In signed number representations, the leftmost bit often serves as the sign bit; overflow can flip this, incorrectly changing the sign of the result

  • Overflow generally leads to incorrect or unpredictable results as the extra bits are truncated or wrapped around

overflow

An overflow occurring after a binary addition

Binary Subtraction

  • As well as adding binary numbers, we can also subtract binary numbers

  • One method of doing this is to use two’s complement

Example 1

Subtract 0011 (3) from 1001 (9)

1. Given numbers

Number 1

0

0

1

1

Number 2

1

0

0

1

2. Two’s complement

  • Convert the number to subtract (0011) to its two’s complement

  • Invert: 1100

  • Add 1: 1100 + 0001 = 1101

Number 1

1

0

0

1

Number 2 (Converted)

1

1

0

1

3. Addition operation

  • Now add 1001 and 1101

  • Binary sum: 1001 + 1101 = 1 0110

  • That’s 5 bits: the leftmost 1 is overflow (carry out of MSB)

Carry

1

 

 

1

 

Number 1

 

1

0

0

1

Number 2

 

1

1

0

1

Addition

1

0

1

1

0

4. Remove overflow

  • The result is 10110 with overflow

  • Drop the leading 1 (overflow): 0110 = 6 (in decimal)

  • In two’s complement arithmetic, the overflow bit does not contribute to the actual value of the operation but is more of a by-product of the method

  • Final answer = 6

  • 9 – 3 = 6

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注