Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! I need help with this code. I need to change the output of this code and integrate overflow and underflow to it. With what

Hello! I need help with this code. I need to change the output of this code and integrate overflow and underflow to it. With what you can help me I will appreciate it. that the output looks different and change the variable name please

image text in transcribed

#include

using namespace std;

typedef union {

float f; struct { unsigned int mantissa : 23; unsigned int exponent : 8; unsigned int sign : 1;

} obj; } mf;

void BinConvertor(int n, int i) { int k; for (k = i - 1; k >= 0; k--) {

if ((n >> k) & 1) printf("1"); else printf("0"); } }

void printFPN(mf var, int exp, int mant) { printf("%d | ", var.obj.sign); BinConvertor(var.obj.exponent, exp); printf(" | "); BinConvertor(var.obj.mantissa, mant); printf(" "); }

int main() { int exp, mant; mf var; float num; cout > num; var.f = num; cout > mant; cout > exp; printf("Floating Point number equivalent to %f is : ", var.f); printFPN(var, exp, mant);

return 0; }

1 #include using namespace std; typedef union { float f; struct { unsigned int mantissa : 23; unsigned int exponent : 8;|| unsigned int sign : 1; 1 obj; mf; void BinConvertor (int n, int i) { int k; for (k = i - 1; k >= 0; k--) { if ((n >> k) & 1) printf("1"); else printf("0"); 11 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 void printFPN (mf var, int exp, int mant) printf("%d", var. obj.sign); BinConvertor (var. obj.exponent, exp); printf(" "); BinConvertor (var.obj.mantissa, mant); printf(" "); } int main() { int exp, mant; mf var; float num; cout>num; var.f = num; cout>mant; cout>exp; printf("Floating Point number equivalent to printFPN (var, exp, mant); %f is : ", var.f); return 0; 1 #include using namespace std; typedef union { float f; struct { unsigned int mantissa : 23; unsigned int exponent : 8;|| unsigned int sign : 1; 1 obj; mf; void BinConvertor (int n, int i) { int k; for (k = i - 1; k >= 0; k--) { if ((n >> k) & 1) printf("1"); else printf("0"); 11 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 void printFPN (mf var, int exp, int mant) printf("%d", var. obj.sign); BinConvertor (var. obj.exponent, exp); printf(" "); BinConvertor (var.obj.mantissa, mant); printf(" "); } int main() { int exp, mant; mf var; float num; cout>num; var.f = num; cout>mant; cout>exp; printf("Floating Point number equivalent to printFPN (var, exp, mant); %f is : ", var.f); return 0

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

More Books

Students also viewed these Databases questions