Converting floating point number to Q-notation fixed point number in C/Java? I am trying to convert from a floating point number to a Q-notation signed 16-bit fixed point number (e.g. Q15). How can this be done in C or Java? I searched online but could not find any available code.
If your floating point number is X, then 

X_Q15 = 32768 * X  

if (X_Q15 > 32767)
    X_Q15 = 32767;  

if (X_Q15 &lt; -32768)
    X_Q15 = -32768;