title: Arithmetic calculations and decimals
body: <p>Please have a look at the code below and explain to me why there is a deviance in the final results. Note that the difference is the introduction of the brackets in the second calculation. Thanks!</p>
  
  <p>Code:</p>
  
  <pre><code>DECLARE  @A decimal(38,19) = 7958011.98
  DECLARE  @B decimal(38,19) = 10409029441
  DECLARE  @C decimal(38,19) = 10000000000
  
  DECLARE  @Z1 decimal(38,19)
  DECLARE  @Z2 decimal(38,19)
  
  
  SET @Z1 = @A * @B / @C
  SET @Z2 = @A * (@B / @C)
  
  SELECT  @Z1 AS [Correct], 
          @Z2 AS [Wrong]
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>Correct = 8283518.0991650000000000000
  Wrong   = 8283510.5860060000000000000
  </code></pre>