Answered step by step
Verified Expert Solution
Link Copied!

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 */
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions