Back to 课程

Computer Science AS OCR

0% Complete
0/0 Steps
  1. 1-1-structure-and-function-of-the-processor as
    5 主题
  2. 1-2-types-of-processor as
    3 主题
  3. 1-3-input-output-and-storage as
    2 主题
  4. 2-1-systems-software as
    8 主题
  5. 2-3-software-development as
    5 主题
  6. 2-4-types-of-programming-language as
    4 主题
  7. 3-1-compression-encryption-and-hashing as
    3 主题
  8. 3-2-databases as
    3 主题
  9. 3-3-networks as
    8 主题
  10. 3-4-web-technologies as
    13 主题
  11. 4-1-data-types as
    8 主题
  12. 4-2-data-structures as
    4 主题
  13. 4-3-boolean-algebra as
    1 主题
  14. 5-1-computing-related-legislation as
    4 主题
  15. 5-2-moral-and-ethical-issues as
    9 主题
  16. 6-1-thinking-abstractly as
    3 主题
  17. 6-2-thinking-ahead as
    1 主题
  18. 6-3-thinking-procedurally as
    3 主题
  19. 6-4-thinking-logically as
    2 主题
  20. 6-5-thinking-concurrently as
    2 主题
  21. 7-1-programming-techniques as
    9 主题
  22. 8-1-standard-algorithms-and-big-o-notation as
    8 主题
课 Progress
0% Complete

Exam code:H046

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

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