Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this project, you will implement a function to convert a decimal floating-point number to and from) IEEE 754 floating point representation (32 bit only).
In this project, you will implement a function to convert a decimal floating-point number to and from) IEEE 754 floating point representation (32 bit only). The steps associated with converting a floating-point number to IEEE 754 is provided in the lecture slide. You will need to implement all the steps in a separate function. For this implementation you are required to use Python. Implementation Details: convert_float_binary(n): Takes a floating point number as input (i.e. n) and return the binary for that number. >>> def convert_float_binary(n): ** Your Code ** >>> convert_float_binary (85.125) The Binary representation of the number is : 1010101.001 calculate_sign_bit(n): Based on the floating point number generates 1 if the number is negative and 0 if the number is positive. >>> def calculate_sign_bit(n): ** Your Code ** >>> calculate_sign_bit(-85.125) The sign is negative with a sign bit : 1 normalize_binary(bin): Takes the binary for the floating-point number and returns the mantissa/fraction and exponent. >>> def normalize_binary (n): ** Your Code ** >>> normalize_binary (1010101.001) Mantissa: 010101001 exponent: 6 calculate_biased_exponent(expo): Takes the exponent from normalized representation and returns the binary of the biased exponenet. >>> def calculate_exponent_biased (n): Your Code ** >>> calculate_exponent_biased (6) The exponent is : 6 and biased exponent is : 10000101 float_to_IEEE754_rep(float_number): Takes the floating point number as an input and generates the IEEE 754 representation. >>> def IEEE 754_rep (float_number): ** call the methods in proper order to calculate the IEEE 754 representation as a string ** >>> IEEE754_rep (85.125): The IEEE 754 single precision for 85.125 is : 0-10000101-01010100 100000000000000 You should also implement the reverse operation i.e. given a binary number in IEEE 754 format it should be able to convert to a floating-point number. In this case, make sure that your top-level function name is ieee_754_to_float. >>> def ieee_754_to_float(n): ** Your Code ** >>> ieee_754_to_float('01000010101010100100000000000000") The float number for the given binary is 85.125
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