title: Optimizing a multiplicator in a nested C++ loop
body: <p>Hello I have the following snippet</p>
  
  <pre><code>  for(int k = 0; k&lt; 1000; ++k)
      {
  
          double acc = 1.0;
  
          if(...)
          {
              short amSeq = 100;
  
              for (short c = 0; c &lt;= 21; ++c)
              {
                  for (short kk = (Range.uSequences[k][c]), s = SeqComp[c]; kk != 0; --kk, --s, --amSeq)
                  {
                      acc *= static_cast&lt;double&gt;(s) / amSeq;
                  }
              }
          }
          else
              acc = 0;
  
      }
  </code></pre>
  
  <p>I was wondering if there is any way to optimize the line <code>acc *= static_cast&lt;double&gt;(s) / amSeq;</code> removing the static_cast speeds up things by a factor of 200 but will obviously yield incorrect results. Thanks</p>