title: In C# unity from optimization point of view should we multiply a data type with numbers directly or every number should be stored in variables
body: <p>Is it important to store all the values in variables that we are going to use for mathematical calculations? Or its okay if I multiply a result / variable directly with float number specially when its going to be executed every frame.</p>
  <p>For example I have to apply a calculated force to my player. Which is the best optimized way from following 2 methods, and how?</p>
  <p>Code 1 : Multiply directly</p>
  <pre><code>Rigidbody Player;
  
  void Update()
  {
      Player.AddForce(Vector3.forward * 2.5f * 4.5f * 2);
  }
  </code></pre>
  <p>or</p>
  <pre><code>Code 2 : Store values in variables and then use
  
  float speed = 2.5f;
  float speed_multiplier = 4.5f;
  float additional_force = 2;
  float resultant_force;
  Rigidbody Player;
  
  void Update()
  {
      resultant_force = speed * force_multiplier * additional_force;
      Player.AddForce(Vector3.forward * resultant_force);
  }
  </code></pre>
  <p>Which one calculates faster without caching extra memory. Which is better from CPU calculations and memory optimization point of view?</p>
  <p>Thank you.</p>