/* Test code for floating point parsing You will want to test more numbers - this is by no means exhaustive Shamelessly taken from Project 2 Spring 2007. Modified by Omar Akkawi for Project 2 Spring 2008 and then modified even more for Project 2 Summer 2008. File Version: 0.01 */ #include #include // Base code definitions #include "fp.h" // Student definitions #include "student.h" int main() { char buf[256]; uint16_t num; fixed_point_t val; // Ensure clean printing until your sprint_half function is complete buf[0] = '\0'; //hex num = 0xfc1a; val = float_half_conversion(num,BINARY_POINT); printf_converted_float(val); printf(" should be: -NaN\n"); val = float_half_conversion(num,EXPONENT_NOTATION); printf_converted_float(val); printf(" should be: -NaN\n"); num = 0x7c00; val = float_half_conversion(num,BINARY_POINT); printf_converted_float(val); printf(" should be: infinity\n"); val = float_half_conversion(num,EXPONENT_NOTATION); printf_converted_float(val); printf(" should be: infinity\n"); num = 0x0001; val = float_half_conversion(num,BINARY_POINT); printf_converted_float(val); printf(" should be: 0b0.000000000000000000000001\n"); val = float_half_conversion(num,EXPONENT_NOTATION); printf_converted_float(val); printf(" should be: 0b1.0E-11000\n"); num = 0x8000; val = float_half_conversion(num,BINARY_POINT); printf_converted_float(val); printf(" should be: -0\n"); val = float_half_conversion(num,EXPONENT_NOTATION); printf_converted_float(val); printf(" should be: -0\n"); num = 0x8400; val = float_half_conversion(num,BINARY_POINT); printf_converted_float(val); printf(" should be: -0b0.00000000000001\n"); val = float_half_conversion(num,EXPONENT_NOTATION); printf_converted_float(val); printf(" should be: -0b1.0E-1110\n"); return 0; }