Question: BELOW IS MY CODE WHERE IM TRYING TO DISPLAY A MENU THAT LETS SOMEONE CONVERT A NUMBER THEY CHOOSE TO IEEE SINGLE PRECISION I NEED

BELOW IS MY CODE WHERE IM TRYING TO DISPLAY A MENU THAT LETS SOMEONE CONVERT A NUMBER THEY CHOOSE TO IEEE SINGLE PRECISION

I NEED HELP WRITING FUNCTIONS TO DISPLAY THE EXPONENT VALUE IN BINARY, TO DISPLAY THE IEEE SINGLE PRECISION BINARY FORMAT, AND TO DISPLAY THE MANTISSA AND HEXADECIMAL CONVERSIONS.

CORRECT ANY ERRORS AS WELL, THANK YOU

#include  #include  #include  using namespace std; //Function Prototypes void signbit(double number, string& x); // checks sign of number; positive (0) or negative (1) void isolate(double number, int& whole, double& fraction); // separates the integer value from the decimal value (ex. -10.25) string wholeconverter(int whole); // converts the integer value to binary (ex. 10 = 1010) string fractionconverter(double number); // converts the decimal value to binary (ex. 0.25 = 0100 0000 0000 0000 0000 0000) string numberconverter(string wholebinary, string fracbin); // converts number entered into binary (ex. 10.25 = 00001010.0100000000000....) string mantissaconverter(string wholebinary, string fracbin); //displays mantissa of converted number (ex. 01001000 00000000 .....) string exponentconverter(string fullbinary); //converts integer of entered number into binary (ex. 130 = 10000010) void fullconverter(string fracbin); //displays entered number in IEEE 754 single precision binary (ex. -10.25 = 01000001 00100100 00000000 00000000) void hexconverter(double number); //displays entered number into IEEE 754 single precision HEX (ex. -10.25 = C1240000) void options(double); void input(double&); //C++ entry point int main() { double number = 0.0; input(number); options(number); return 0; } void input(double& number) { cout << "Please Input a Number: " << endl; cin >> number; } //This is our options function that contolls our info void options(double number) { while (true) { //Declaration string x; // Sign string wholebinary, fracbin, fullbinary, mantissa; int whole, exponent; double fraction, binary; char choice, hex; //Initialization fraction = 0.00; exponent = 0; whole = 0; binary = 0.00; hex = 0; choice = 0; x = ""; fracbin = ""; wholebinary = ""; fullbinary = ""; mantissa = ""; // Menu Display cout << " " << endl; cout << "PLEASE CHOOSE ONE OF THE FOLLOWING OPERATIONS: " << endl; cout << "1. DISPLAY THE SIGN BIT VALUE" << endl; cout << "2. DISPLAY THE INTEGER PART IN BOTH BASE-10 AND BINARY FORMATS" << endl; cout << "3. DISPLAY THE DECIMAL PART IN BOTH BASE-10 AND BINARY FORMATS" << endl; cout << "4. DISPLAY THE NUMBER ENTERED IN BOTH BASE-10 AND BINARY FORMATS" << endl; cout << "5. DISPLAY THE MANTISSA IN BINARY FORMAT" << endl; cout << "6. DISPLAY THE EXPONENT IN BOTH BASE-10 AND BINARY FORMAT" << endl; cout << "7. DISPLAY THE IEEE 754 SINGLE PRECISION BINARY FORMAT" << endl; cout << "8. DISPLAY THE IEEE 754 SINGLE PRECISION HEX FORMAT" << endl; cout << " " << endl; signbit(number, x); isolate(number, whole, fraction); wholebinary = wholeconverter(whole); fracbin = fractionconverter(fraction); fullbinary = numberconverter(wholebinary, fracbin); mantissa = mantissaconverter(wholebinary, fracbin); //exponentconverter = wholeconverter(exponent); part 6 // you need to make a binary variable that is = x+exponentbinary+mantissa part 7 //0010 0110 // if (4bin == "0010"){ // hexstr = hextr+"2"} //Operation Selection cin >> choice; switch (choice) { case '1': signbit(number, x); // Function Call if (number >= 0) { cout << "SIGN BIT IS (" << x << ") SINCE THE NUMBER ENTERED IS POSITIVE." << endl; } else { cout << "SIGN BIT IS (" << x << ") SINCE THE NUMBER ENTERED IS NEGATIVE." << endl; } break; case '2': //isolate(number, whole, fraction); // Function Call wholebinary = wholeconverter(whole); // Function Call cout << "NUMBER (" << abs(whole) << ") IN BASE-10 IS EQUAL TO (" << wholebinary << ") IN BINARY" << endl; break; case '3': //isolate(number, whole, fraction); // Function Call //wholebinary = wholeconverter(whole); // fracbin = fractionconverter(fraction); // Function Call cout << "NUMBER (" << abs(fraction) << ") IN BASE-10 IS EQUAL TO (" << fracbin << ") IN BINARY" << endl; break; case '4': //isolate(number, whole, fraction); //Function Call //wholebinary = wholeconverter(whole); // //fracbin = fractionconverter(fraction); // Function Call fullbinary = numberconverter(wholebinary, fracbin); cout << "NUMBER(" << abs(number) << ") IN BASE-10 IS EQUAL TO (" << fullbinary << ") IN BINARY" << endl; break; case '5': isolate(number, whole, fraction); //Function Call wholebinary = wholeconverter(whole); // fracbin = fractionconverter(fraction); // Function Call fullbinary = numberconverter(wholebinary, fracbin); mantissa = mantissaconverter(wholebinary, fracbin); // Function Call cout << "MANTISSA IS (1." << mantissa << ") IN BINARY." << endl; break; case '6': exponentconverter(fullbinary); // Function Call cout << "NUMBER (" << abs(number) << ") IN BASE - 10 IS EQUAL TO("<< fullbinary<< ") IN BINARY" << endl; break; case '7': //fullconverter(fracbin); // Function Call break; case '8': //hexconverter(number); // Function Call break; default: cout << "INVALID INPUT" << endl; break; } } } ///////////////////////////////////////////////// // signbit function // checks the sign of the number, positive or negative // void type // 2 parameters; one pass by value (number) and one pass by reference (&x) // number, &x void signbit(double number, string& x) { if (number >= 0.00) { x = '0'; } else { x = '1'; } } //////////////////////////////////////////////////// // isolate function // void function // seperates the integer value from the decimal value // 3 parameters; one pass by value and two pass by reference // number, whole, fraction void isolate(double number, int& whole, double& fraction) { // declartion //int whole; //double fraction; // initialization fraction = 0.0; whole = 0; whole = (int)number; fraction = number - whole; //cout << whole << endl << fraction << endl; // no return statment //return a, b, c, d; only the one before the ; will be reported back } /////////////////////////////////////////////////// // wholeconverter function // string function // Converts the integer value to binary // 1 parameter; pass by value // whole string wholeconverter(int whole) { //declaration string wholeb; //initialization wholeb = ""; if (whole < 0) whole = whole * -1; whole = abs(whole); while (whole > 0) { if (whole % 2 == 0) { wholeb = "0" + wholeb; } else { wholeb = "1" + wholeb; } whole = whole / 2; } return wholeb; } //////////////////////////////////////// // fractionconverter function // string function // converts the decimal value to binary // 1 parameter, pass by value // fraction string fractionconverter(double num) { // result string result = ""; int flag = 0; //if (num <0) num = num * -1; //big O num = abs(num); while (flag <= 30) // number of position mantissa precision { flag++; // increment for precision num = num * 2; if (num >= 1) { result = result + '1'; num = num - 1; // num = num - (int)num; } else result = result + '0'; } return result; } //////////////////////////////////////// // numberconverter function // string type // displays the number entered into binary format // 2 parameters, both pass by value // number, fracbin string numberconverter(string wholebinary, string fracbin) { string result = ""; result = wholebinary + "." + fracbin; return result; } //////////////////////////////////////// // mantissaconverter function // string type // displays the mantissa of the converted number in binary format // 1 parameter, pass by value // mantissa string mantissaconverter(string wholebinary, string fracbin) { string result = ""; result = wholebinary + fracbin; string mantissa(result, 1, 24); if (mantissa.substr(1, 23) == "1") { mantissa = mantissa.substr(0, 22) + "1"; } mantissa = mantissa.substr(1, 30); return mantissa; } //////////////////////////////////////// // exponentconverter function // string type // converts the exponent of the entered number into binary format // 1 parameter, pass by value // exponent string exponentconverter(string fullbinary) { string exponent = ""; exponent = fullbinary.length() - 1; return 0; } void hexconverter(double number) { }

DO NOT GIVE ME A BREAKDOWN OF THE CODE, I AM ASKING FOR HELP DEVELOPING THE FUNCTIONS

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!