title: Floating point linear interpolation
body: <p>To do a linear interpolation between two variables <code>a</code> and <code>b</code> given a fraction <code>f</code>, I'm currently using this code:</p>
  
  <pre><code>float lerp(float a, float b, float f) 
  {
      return (a * (1.0 - f)) + (b * f);
  }
  </code></pre>
  
  <p>I think there's probably a more efficient way of doing it. I'm using a microcontroller without an FPU, so floating point operations are done in software. They are reasonably fast, but it's still something like 100 cycles to add or multiply.</p>
  
  <p>Any suggestions?</p>
  
  <p><em>n.b. for the sake of clarity in the equation in the code above, we can omit specifying <code>1.0</code> as an explicit floating-point literal.</em></p>