This assignment demonstrates converting from a floating point number to an integer using only integer and bitwise operations.
You will create implementations for the following functions:
is_negative
get_raw_exponent
get_exponent
get_raw_mantissa
get_mantissa
float_to_int
The first five functions provide the framework to create a software-based float to int converter. These function will then be combined to create a float to int converter in the function float_to_int
.
This tool may be useful for exploring floating point numbers.
The IEEE Standard for Floating-Point Arithmetic includes a number of special cases. The implementation in this assignment need only properly handle normal numbers. It could be extended to support other numbers, such as zero.
The included makefile will build the fp.c file and run a series of tests to confirm that a valid implementation has been added to the file. The tests can be run by executing:
make test
It is strongly recommend to read the tests included at the bottom of the fp.c
program in order to help understand the specification for each of the functions to be implemented.