Question: Adding numbers in binary In this lab, our objective is to write functions that can add numbers in binary. Binary addition is normally performed by
Adding numbers in binary
In this lab, our objective is to write functions that can add numbers in binary. Binary addition is normally
performed by adder circuits within the ALU a subsystem of the CPU In this lab, we will emulate the behavior
of the ALU by using a function that adds numbers.
Write a function addnumbersab that adds two binary numbers a and b stored on bits, and that
returns the output in binary on bits.
What could happen if the output was stored on bits? Give an example
Hints:
use strings numbers between quotes to define a and b so you can manipulate them more easily
Rules of binary addition:
Example addition in binary:
Remember that a and b may not have the same number of digits, and that c can have more digits than
a or b see above example for instance
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
