title: Fixed-point scaling and accuracy in multiplication
body: <p>I need to perform a multiplication operation on a fixed-point variable <code>x</code> (unsigned 16-bit integer [U16] type with binary point 6 [BP6]) with a coefficient <code>A</code>, which I know will always be between 0 and 1. Code is being written in C for a 32-bit embedded platform.</p>
  
  <p>I know that if I were to also make this coefficient a U16 BP6, then I would end up with a U32 BP12 from the multiplication. I want to rescale this result back down to U16 BP6, so I just lop off the first 10 bits and the last 6.</p>
  
  <p>However, since the coefficient is limited in precision by the number of fractional bits, and I do not necessarily need the full 10 bits of integer, I was thinking that I could just make the coefficient variable <code>A</code> a U16 BP15 to yield a more precise result.</p>
  
  <p>I have worked out the following example (bear with me):</p>
  
  <p>Let's say that <code>x = 172.0</code> (decimal) and I want to use a coefficient <code>A = 0.82</code> (decimal). The ideal decimal result would be 172.0 * 0.82 = 141.04.</p>
  
  <p>In binary, <code>x = 0010101100.000000</code>.</p>
  
  <p>If I am using BP6 for A, the binary representation will be either</p>
  
  <pre><code>    A_1 = 0000000000.110100 = 0.8125 or
      A_2 = 0000000000.110101 = 0.828125
  </code></pre>
  
  <p>(depending on whether value is based on floor or ceiling).</p>
  
  <p>Performing the binary multiplication between x and either value of A yields (leaving out leading zeroes):</p>
  
  <pre><code>    A_1 * x = 10001011.110000000000 = 139.75 
      A_2 * x = 10001110.011100000000 = 142.4375
  </code></pre>
  
  <p>In both cases, triming down the last 6 bits would not affect the result.</p>
  
  <p>Now, if I expanded A to have BP15, then</p>
  
  <pre><code>    A_3 = 0.110100011110110 = 0.82000732421875
  </code></pre>
  
  <p>and the resulting multiplication yields</p>
  
  <pre><code>    A_3 * x = 10001101.000010101001000000000 = 141.041259765625
  </code></pre>
  
  <p>When trimming the extra 15 fractional bits, the result is </p>
  
  <pre><code>    A_3 * x = 10001101.000010 = 141.03125
  </code></pre>
  
  <p>So it's pretty clear here that by expanding the coefficient to have more fractional bits yields a more precise result (at least in my example). Is this something which will hold true in general? Is this good/bad to use in practice? Am I missing or misunderstanding something?</p>
  
  <p>EDIT: I should have said "accuracy" in place of "precision" here. I am looking for a result which is closer to my expected value rather than a result which contains more fractional bits.</p>