Part 2: Binary Arithmetic One of the most common operations we perform on binary numbers (and all numbers) is addition. It can be cumbersome to convert your binary numbers to decimal just to add them and convert them back, so instead we will be learning how to add binary numbers directly. Binary addition works the same way as decimal addition, with the added restriction that each digit can only go up to 1. Let's consider the possibilities for adding the values of any 2 single digits together: 0 + 0 0 + 1 1 + 0 1 + 1 0 1 1 10 (remember that 10 in binary represents the number 2) In that last case, the result is larger than a single digit. When adding larger binary numbers, that means we have to carry the 1 over to the next column. This presents us with another new case: what happens if we have 1 + 1 + carried 1? In that case, the result is 11, which means that column's result is 1, and we carry 1 to the next column. Below is an example of adding two binary numbers that shows all cases:  carry:  1 1 1 1                                  in decimal              0 1 1 0 1 1 0 0                           108           + 0 0 1 1 1 0 1 0          =           +   58              1 0 1 0 0 1 1 0                           166 first column (1's place):         0 + 0 = 0 second column (2's place):    0 + 1 = 1 third column (4's place):        1 + 0 = 1 fourth column (8's place):     1 + 1 = 0, carry 1 fifth column (16's place):       0 + 1 + carried 1 = 0, carry 1 sixth column (32's place):      1 + 1 + carried 1 = 1, carry 1 seventh column (64's place): 1 + 0 + carried 1 = 0, carry 1 last column (128's place):      0 + 0 + carried 1 = 1    Exercise 4: What is 10001000 + 00101000? Show the result in binary. Exercise 5: What is 00011111 + 11000101? Show the result in decimal.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

Part 2: Binary Arithmetic

One of the most common operations we perform on binary numbers (and all numbers) is addition. It can be cumbersome to convert your binary numbers to decimal just to add them and convert them back, so instead we will be learning how to add binary numbers directly.

Binary addition works the same way as decimal addition, with the added restriction that each digit can only go up to 1. Let's consider the possibilities for adding the values of any 2 single digits together:

0 + 0 0 + 1 1 + 0 1 + 1
0 1 1 10

(remember that 10 in binary represents the number 2)

In that last case, the result is larger than a single digit. When adding larger binary numbers, that means we have to carry the 1 over to the next column. This presents us with another new case: what happens if we have 1 + 1 + carried 1? In that case, the result is 11, which means that column's result is 1, and we carry 1 to the next column. Below is an example of adding two binary numbers that shows all cases:

 carry:  1 1 1 1                                  in decimal

             0 1 1 0 1 1 0 0                           108

          + 0 0 1 1 1 0 1 0          =           +   58

             1 0 1 0 0 1 1 0                           166

first column (1's place):         0 + 0 = 0

second column (2's place):    0 + 1 = 1

third column (4's place):        1 + 0 = 1

fourth column (8's place):     1 + 1 = 0, carry 1

fifth column (16's place):       0 + 1 + carried 1 = 0, carry 1

sixth column (32's place):      1 + 1 + carried 1 = 1, carry 1

seventh column (64's place): 1 + 0 + carried 1 = 0, carry 1

last column (128's place):      0 + 0 + carried 1 = 1 

 

Exercise 4: What is 10001000 + 00101000? Show the result in binary.

Exercise 5: What is 00011111 + 11000101? Show the result in decimal.

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Lower bounds sorting algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr