Question: I need help. i understand how to represent numbers in floating point representation after the lecture in class. the homework assigned is quite difficult though.

I need help. i understand how to represent numbers in floating point representation after the lecture in class. the homework assigned is quite difficult though. appreciate it thank you!

Question 1: Write down an function named bitwisedFloatCompare(float number1, float number2) that tests whether a floating point number number1 is less than, equal to or greater than another floating point number number2, by simply comparing their floating point representations bitwise from left to right, stopping as soon as the first differing bit is encountered. The fact that this can be done easily is the main motivation for biased exponent notation. The function should return 1 if number1 > number2, return -1 if number2 > number1 and should return 0 if the two numbers are equal. Please note the solution is constrained to be implemented using bitwise comparison of the two numbers. Question 2: Write a function named printFloatRepresentation(float number) that will print the floating point representation of a number using the format given below. (Sign bit) exponent in binary (assumed bit).significand For example if the number passed an argument is 71 your program should print (0) 10000101 (1).00011100000000000000000 Similarly if the number passed to the function as argument is -71 the program should print (1) 10000101 (1).00011100000000000000000 The main function and function skeletons for the two functions are given in the attached C course. Complete the two functions mentioned in the question.

Question 2: Write a function named printFloatRepresentation(float number) that will print the floating point representation of a number using the format given below. (Sign bit) exponent in binary (assumed bit).significand For example if the number passed an argument is 71 your program should print (0) 10000101 (1).00011100000000000000000 Similarly if the number passed to the function as argument is -71 the program should print (1) 10000101 (1).00011100000000000000000 The main function and function skeletons for the two functions are given in the attached C course. Complete the two functions mentioned in the question.

and here the main function that will be used to test functions

/* * FloatingPointRepresentation.c Please do not return this file or the main function with your homework */ #include  int main() { float number1; float number2; int comparison; number1=56; number2=12; comparison=bitwisedFloatCompare(number1,number2) ; // Compare two floating point numbers if (comparison==1) printf(%f is greater than %f ,number1,number2); else if (comparison==-1) printf(%f is greater than %f ,number2,number1); else if (comparison==0) printf(Number are equal ); else printf(Error ); return 0; } 

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!