Question
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
#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 #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started