Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/* Print a float in binary: ftob.c */ #include #include //void float_to_string(float f, char *s, int n); void float_to_string(float,char *,int); void print_float(); #define LEN 32
/* Print a float in binary: ftob.c */
#include
#include
//void float_to_string(float f, char *s, int n);
void float_to_string(float,char *,int);
void print_float();
#define LEN 32
#define EXP_32 8 /* ending index of s for exponent */
#define MAN_32 9 /* starting index of s for significand */
int main(int argc, char **argv) {
int n=LEN;
float f;
char s[LEN];
f = atof(argv[1]);
printf("f=%f ",f);
float_to_string(f,s,n);
print_float(s,n);
return 0;
}
/* convert float to binary and store in s, a string of 32 chars */
void float_to_string(float f, char *s, int n){
unsigned int u_int;
int i; /* for loop index */
/* fill here */
}
/* print space in between sign bit, exponent, and significand */
void print_float(char *s, int n) {
int i=0;
/* fill here */
}
/* End of ftob.c */
Step 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