title: Is arithmetic commutative and associative?
body: <p>In maths, addition (of real numbers) is commutative and associative, ie. for all numbers x, y and z</p>
  
  <blockquote>
    <p>x + y = y + x (commutativity)</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>x + (y + z) = (x + y) + z (associativity)</p>
  </blockquote>
  
  <p>Multiplication of real numbers is also commutative and associative. But is this true for ints and floats in .NET? Counterexamples welcome.</p>
  
  <p>Edit: Background is we've recently parallelised an algorithm and now its results are no longer consistent between repeats. I speculate this might be due to the atomic calculations returning (and being merged) in non-deterministic order. In which case, the inconsistency could be fixed by a smarter (but slower) merge algorithm (that sorts the results before merging). I'd like to know what assumptions it can make about .NET arithmetic. </p>