title: Is it useful to have intermediate results in doubles, when input and output are floats?
body: <p>I am wondering about the following: I have a method that takes a float as input and returns a float after some calculation. The calculations may involve anything like addition, division, logarithms, powers etcetera. While doing so, the intermediate result needs to be stored several times. Something crazy like this:</p>
  
  <pre><code>float performSomeComputations(float value)
  {
      // addition, substraction, logarithms, multiplication, etcetera
      float a = value * 12.0;
      float b = math.pow(a, 34.0);
      float c = math.log10(b +  value - 567);
      return a + b + c;
  }
  </code></pre>
  
  <p>My question is: does it matter how you store the intermediate results? I.e. as <code>float</code> or as <code>double</code>? Let us assume that the intermediate values don't exceed the minimum and/or maximum value, obviously there will be a difference then. But would the return value be more accurate if <code>double</code> types are used, or would you get always exactly the same answer, after it's finally cast back to <code>float</code>? And is it possible that the answer could vary per programming language?</p>