/* The IEEE 754 standard regarding floating point representations does not provide a specification for 8-bit floating point numbers. Imagine, however, that such numbers adhere to the following format: x x x x x x x x (sign) (exponent) (mantissa) That is, 1 sign bit, 3 exponent bits, and 4 bits for the mantissa. Write a program that prompts a user to enter 8 bits and outputs the decimal equivalent. Make sure the result is printed with three digit precision (i.e., "%.3f" in printf). (Hint: The exponent bias for this 8-bit representation is 3) ============= START OF SAMPLE RUN ======================= Enter 8-bit floating point number: 0 0 0 0 0 0 0 0 The decimal value is 0.125 ============= END OF SAMPLE RUN ======================= ============= START OF SAMPLE RUN ======================= Enter 8-bit floating point number: 1 1 0 1 0 1 1 0 The decimal value is -5.500 ============= END OF SAMPLE RUN ======================= */ #include #include #define BIAS 3 int main() { int d1, d2, d3, d4, d5, d6, d7, d8; double sign, exponent, mantissa, result; printf("Enter 8-bit floating point number:\n"); scanf("%d %d %d %d %d %d %d %d", &d1, &d2, &d3, &d4, &d5, &d6, &d7, &d8); sign = pow(-1, d1); exponent = 4*d2 + 2*d3 + d4 - BIAS; mantissa = 1 + 0.5*d5 + 0.25*d6 + 0.125*d7 + 0.0675*d8; result = sign * pow(2, exponent) * mantissa; printf("The decimal value is %.3f\n", result); system("pause"); return 0; }