Question: NEED THE SINGLE PRECISION CODE TO FINISH THE LAB, USE MY CODE AS A HEADSTART AND JUST FINISH THE REST OF THE REQUIREMENTS JUST SEND




IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII /I II II \#include \#include> using namespace std; I/ global var. II prototypes void collect(double\& x ); double collect20; void sign_collector (double x, char\& s); void isolate(double, int\&, double\&); void display (char sign, int intpart, double decpart, string, string ); void inttobin(int intpart, string\& binarystring, int); void decimaltobinary (double decpart, string\& decimalbinary); void exponentval(string binarydata, int exponent); int main() \{ // declarations/ initialization double number =0.0; char sign; int intpart =0; double decpart =0.0; string integerbinary ="; string decimalbinary ="; int bits =8; string binarydata =; int exponent =0; // 1. ask the user to enter the value to convert to IEEE collect(number); // number =collect2(); /I 2. find the sign b sign_collector(number, sign); //3. function to isolate integer part from the decimal // 10.25 - integerpart =10, decimalpart =0.25 isolate(number, intpart, decpart); //4. convert intpart to binary inttobin(intpart, integerbinary, bits); //inttobin(intpart, binarystring, 8); // 5 function to convert the decimal part to binary decimaltobinary(decpart, decimalbinary); //6. calculating exponent binarydata = integerbinary +"."+ decimalbinary; exponentval(binarydata, exponent); II 7. after normlization (mantissa) II. conversion to hex 00000 00011 1010 1110E 1111F // display display(sign, intpart, decpart, integerbinary, decimalbinary); return 0; \} II II communicating via pass by reference void collect(double 8x ) f I/ 1. ask the user to enter the value to convert to IEEE cout "Please enter a value to convert to IEEE :" end; cinx; 3 III x; // 1. ask the user to enter the value to convert to IEEE cout "Please enter a value to convert to IEEE :" end; cin>; return x; \} IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII II a function to extract a number sign void sign_collector(double x, char \&s) \{ if (x>=0) s= 'O'; // 0 for positive else s=11;//1 for negative \} II a function that takes a double value and returns an integer and a double void isolate(double number, int \& intpart, double\& decpart) f number = abs(number); intpart =abs(( int ) number); // type cast decpart = abs(number intpart); 3 void inttobin(int intpart, string\& binarystring, int bits) \{ for (int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
