/* FloatToFixed converts a float in the range (0,1) to a fixed point 16 bit binary stored as an unsigned integer. It converts negative numbers to zero and numbers bigger than one to the largest fixed point representation available. MaxNum should be a large power of 2 no larger than half of UINT_MAX. */ #include "CORDIC.h" unsigned int FloatToFixed(float x, unsigned int MaxNum){ unsigned int n; if(x<0) n=0; else if(x>1) n=MaxNum; else n = (x*MaxNum); return n; };