Question
In this question you will use the data type bit32 introduced in Lab 2 (i.e. an unsigned int). We will use the IEEE 754 standard
In this question you will use the data type bit32 introduced in Lab 2 (i.e. an unsigned int). We will use the IEEE 754 standard for floating point numbers, with 1 sign bit, 8 bits for the exponent, and 23 bits for the mantissa. For the following programming questions, place each function in a common file fplib.c for compiling and testing. You are not to use any C floating point data types (i.e., float, double). You can use the bitwise operators as needed: and, or, not, xor, shift-right, and shift-left. (a) Write C functions to extract the sign, exponent, and fraction of a bit32 floating point number, returning their respective values as unsigned integers. The functions should be named sign, expon, and frac. (b) Write a function, float_32(unsigned int sign, unsigned int exp, unsigned int frac), that returns a bit32 representation of a number given a sign, exponent, and fraction values as unsigned integers. (c) Using the functions defined in (a) and (b), write a function fp_add(bit32 x, bit32 y) that returns the addition of two bit32 values x and y as a floating point bit32 value.
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