// Fixed point unsigned short usMaxDepth, usPercentO2x10000; usMaxDepth = ((unsigned short)((((unsigned long)(46.2*10000)<<12)Listing 1—This code snippet performs the same calculation in fixed-point and floating-point arithmetic. It partially illustrates the additional complexity involved in using fixed-point math.
/ (unsigned long)usPercentO2x10000)>>12) - 33); // Floating point float fPercentO2; usMaxDepth = (unsigned short)(46.2 / fPercentO2 - 33.0);