title: Why doesn't num2fixpt function return my expected counterpart fixed point value?
body: <p>I am trying to convert from float/double to fixed point notation,  for instance let's use the number <code>x = 0.39</code> as input.</p>
  <p>I would like to convert x into its unsigned 16 bits fixed-point counterpart, to do so in C++ I am accustomed to use the expression <code>xFixedPoint = round(x*2^(16))</code>, this will make that the fixed point version of <code>0.39</code> is <code>25559</code>.</p>
  <p>However, I cannot get that result if I make use of <a href="https://www.mathworks.com/help/simulink/slref/num2fixpt.html" rel="nofollow noreferrer"><code>num2fixpt</code></a> function, I am using it in the following way</p>
  <pre><code>num2fixpt(0.39, ufix(16)) 
  ans = 0 
  </code></pre>
  <p>What am I doing wrong when using <code>num2fixpt</code> function?</p>