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.
1) Write a function addnumbers(a,b) that adds two binary numbers a and b stored on 8 bits, and that
returns the output in binary on 9 bits.
2) What could happen if the output was stored on 8 bits? Give an example
Hints:
1) use strings (numbers between quotes) to define a and b, so you can manipulate them more easily
2) Rules of binary addition:
3) Example addition in binary:
4) 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!