This is the 5.19 format Convert the following binary and hexadecimal numbers to
ID: 3860765 • Letter: T
Question
This is the 5.19 format
Convert the following binary and hexadecimal numbers to oating point format.. Assume a binary format consisting of a sign bit (negative = 1), a base 2, 8-bit, excess-128 exponent, and 23 bits of mantissa, with the implied binary point to the right of the rst bit of the mantissa.
1. Convert the following to the floating point representation using the format in 5.19 of your text: 12526588.125
2. Convert the following from the floating point representation to a decimal (base 10) representation using the format in 5.19 of your text: 10010110010010100011011010101011 please i need all the solutions.
Explanation / Answer
#include #include #include "aschex.h" #define TRUE 1 #define FALSE 0 #define LINE_LENGTH 80 /* Maximum number of characters accepted */ #define FLOAT_HEX_LENGTH 8 /* how many characters in hex IEEE number */ #define HEX_ERROR -1 /* error flag from asc2bin */ char hex_string [LINE_LENGTH + 1]; /* user's entry */ char *index; /* pointer to entry character */ int byte; /* binary value of two hex characters */ unsigned char *special_ptr; /* used to poke bytes into float_value */ float float_value; /* the result, we'll print this */ int hex_counter; /* counts number of hex characters processed */ unsigned char error_flag; /* TRUE if error in hex entry */ /*------------------------------------------------------------------------*/ void main (void) { /* Display welcome message and instructions for use. */ printf (" FLOAT.C - This program converts single-precision IEEE "); printf ("floating-point numbers from hexadecimal to ASCII numeric. "); printf ("Enter the hexadecimal number as eight characters, MSB first. "); printf ("Enter just a carriage return to exit. "); /* Execute the main processing loop forever, until user wants to exit. */ while (TRUE) { /* Prompt for and get the eight-character hexadecimal number. */ printf ("Enter eight-character hexadecimal number (MSB first): "); gets (hex_string); if (strlen (hex_string) == 0) { /* Exit if carriage-return only. */ printf (" Program terminated "); return; } if (strlen (hex_string) != FLOAT_HEX_LENGTH) { printf ("Error, you must enter eight characters "); continue; } /* Convert each pair of hex characters into a binary byte, then poke the byte into the correct position in float_value. The string is processed from MSB to LSB, but float_value is stored in memory from LSB to MSB. */ index = hex_string; /* initialize pointer to hexadecimal characters */ error_flag = FALSE; /* no error in hex entry (yet) */ /* Point at last byte of float_value. */ special_ptr = (& (unsigned char) float_value) + 3; for (hex_counter = 0; hex_counterRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.