Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to add line of codes into the code program below >>> what I need to be add is to make this code

I am trying to add line of codes into the code program below >>> what I need to be add is to make this code program to determine when an overflow exsistes or tell that there is no overflow.
extra more details on the provided pic...
code program;
#include
using namespace std;
char change(char p)
{
if (p == '0')
{
return '1';
}
else
{
return '0';
}
}
void OneTwoComplements(string binary,int n)
{
string oneComp, twoComp;
int i;
oneComp = twoComp = "";
for (i = 0; i
{
oneComp += change(binary[i]);
}
int p;
twoComp = oneComp;
for (p = n - 1;p >= 0;p--)
{
if (oneComp[p] == '1')
{
twoComp[p] = '0';
}
else
{
twoComp[p] = '1';
break;
}
}
if(p == -1)
{
twoComp = '1' + twoComp;
}
cout
cout
}
int main()
{
string binary;
int n;
cout
cin>>n;
cout
cin>>binary;
cout
OneTwoComplements(binary,n);
return 0;
}
image text in transcribed
vale. 4. Program output: (a) The program should notify the user if an overflow occurs. An overflow occurs when the decimal value does not fit within the max/min (magnitude) range of the l's comp and 2's comp Binary number size. (b) If an overflow occurs, the program should notify the user and end the program. (c) Otherwise, if no overflow occurs, the program should notify the user that.no overflow occurs and display the l's comp and 2's comp Binary in the specified bit size)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago