Question: Please write in c. (3) Binary Math Write a program called bitMath.c that asks the user for two 8-bit sequences that correspond to integers stored

 Please write in c. (3) Binary Math Write a program calledbitMath.c that asks the user for two 8-bit sequences that correspond to

Please write in c.

(3) Binary Math Write a program called bitMath.c that asks the user for two 8-bit sequences that correspond to integers stored in the two's compliment representation. It should then add the bit sequences together to produce a resulting bit sequence that is the sum of the two numbers. The program should display the bit sequences as well as their decimal value with output in the format shown in the following output (assuming the program was run 8 times) ase:~$./bitMat Enter 1st 8-bit sequence: 00001010 Enter 2nd 8-bit sequence: 00000111 00001010 (10) 00000111 (7) 00010001 (17) student@COMPBase:~$./bitMath Enter 1st 8-bit sequence: 11110110 11110110 (-10) 11101111 (-17) student@COMPBase:~$./bitMath Enter 1st 8-bit sequence: 10000000 Enter 2nd 8-bit sequence: 00000001 10000000 (-128) 00000001 (1) 10000001 (-127) student@ COMPBase:~$./bitMath Enter 1st 8-bit sequence: 01110011 Enter 2nd 8-bit sequence: 00111001 01110011 (115) 00111001 (57) OVERFLOW DETECTED student@ COMPBase:~$./bitMath Enter 1st 8-bit sequence: 10000000 Enter 2nd 8-bit sequence: 10000001 10000000 (-128) 10000001 (-127) student@ COMPBase:~$./bitMath Enter 1st 8-bit sequence: 000111 Enter 2nd 8-bit sequence: 1001 Error: You must enter two valid 8-bit string sequences student@COMPBase:$ ./bitMath Enter 1st 8-bit sequence: 11hh1139 Enter 2nd 8-bit sequence: kd232811 Error: Bit sequence 1 has non-binary characters student@COMPBase:$./bitMath Enter 1st 8-bit sequence: 10011001 Enter 2nd 8-bit sequence: 10k0 3r43 Error: Bit sequence 2 has non-binary characters To write this code, it makes sense to have at least 4 functions: a main function, a function for flipping bits (for the negative numbers), . a function for adding two bit sequences, and a function for converting a bit sequence to a decimal value It would be good to follow the following steps to obtain your solution systematically. Don't move on until you get each step working: 2. Ensure that each input sequence is 8 characters long 3. Check to ensure that there are only 1's and O's in the bit sequence 4. Display the input sequences along with their decimal equivalents (test only positive numbers) 5. Write the function to add the bit sequences and produce the result (test only positive numbers) 6. Write the function to flip the bits of a sequence 7. Adjust your code to work for negative numbers 8. Add the overflow checking 9. Test thoroughly Test your code thoroughly and hand in the output from your test cases in a file called output.txt. You boundary test cases. If you miss some obvious" boundary test cases, you will lose marks .. so test more than you need if you are not certain

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 Databases Questions!