/* FixedToFloat Converts an unsigned integer (considered as a fixed point binary fraction 0.xxxxxxxxxxxxxx base 2) into a float in the range [0,1). It converts anything larger than the largest fixed point representation (with our constraint) to 1.0 and 0 to 0.0. MaxNum should be the largest power of 2 representable in our unsigned integers. */ float FixedToFloat(unsigned int n, unsigned int MaxNum) { float x; if(n>MaxNum) x=1.0; else {x = n; x = x/MaxNum;}; return x; }