Write a java application to convert decimal number to IEEE-754 Single Precision
ID: 3638557 • Letter: W
Question
Write a java application to convert decimal number to IEEE-754 Single Precision Floating-Point Representation (32-bit) and IEEE-754 Double Precision Floating-Point Representation (64-bit) and convert back to decimal.Explanation / Answer
#include #include void ibm2ieee(void *to, const void *from, int len) { register unsigned fr; /* fraction */ register int exp; /* exponent */ register int sgn; /* sign */ for (; len-- > 0; to = (char *)to + 4, from = (char *)from + 4) { /* split into sign, exponent, and fraction */ fr = ntohl(*(long *)from); /* pick up value */ sgn = fr >> 31; /* save sign */ fr 25; /* save exponent */ fr = -exp & 3; exp = (exp + 3) >> 2; /* (re)normalize */ while (fr < 0x10000000) { /* never executed for normalized input */ --exp; fr 8) | (exp epsm) epsm = eps; if (eps > IBM_EPS) printf("Error: %.8g != %.8g ", f1, f2); } int main() { int i; float f1; epsm = 0.0; for (i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.