Question: /* 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 */
 /* Print a float in binary: ftob.c */ #include #include //void

3. Write a C program to print the binary values of a floating point number passed as a parameter, as demonstrated in class, by filling in ftob.c. For example, it would print "001111110 10000000000000000000000" when you type "ftob 0.75." So would it "o 0ll11101 00110011001100110011010" when you type "ftob 0.3" as demonstrated

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!