/* 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. File Version: 0.02 Changes from version 0.01: Added include of fp.h Changed all test calls to sprint_half to match new requirements. */ #include #include // The prototype for sprint_half, as well as the format_t type #include "fp.h" int main() { char buf[256]; uint16_t num; // Ensure clean printing until your sprint_half function is complete buf[0] = '\0'; //hex num = 0xfc1a; sprint_half(buf,num,BINARY_POINT); printf("%s should be: -NaN\n",buf); sprint_half(buf,num,EXPONENT_NOTATION); printf("%s should be: -NaN\n",buf); num = 0x7c00; sprint_half(buf,num,BINARY_POINT); printf("%s should be: infinity\n",buf); sprint_half(buf,num,EXPONENT_NOTATION); printf("%s should be: infinity\n",buf); num = 0x0001; sprint_half(buf,num,BINARY_POINT); printf("%s should be: 0b0.000000000000000000000001\n",buf); sprint_half(buf,num,EXPONENT_NOTATION); printf("%s should be: 0b1.0E-11000\n",buf); num = 0x8000; sprint_half(buf,num,BINARY_POINT); printf("%s should be: -0\n",buf); sprint_half(buf,num,EXPONENT_NOTATION); printf("%s should be: -0\n",buf); num = 0x8400; sprint_half(buf,num,BINARY_POINT); printf("%s should be: -0b0.00000000000001\n",buf); sprint_half(buf,num,EXPONENT_NOTATION); printf("%s should be: -0b1.0E-1110\n",buf); return 0; }