title: MySQL numeric operation oddities - overflow?
body: <p>What is wrong with this first query on MySQL?</p>
  
  <p>The expected answer for both columns is '718042670591505846'</p>
  
  <pre><code>SELECT 5002622390 + (5102 * 140737488355328) new_iid_hard_way,
       CAST(5002622390 + (5102 * POWER(2,47)) AS UNSIGNED) new_iid_WRONG_way
  </code></pre>
  
  <p>It returns:</p>
  
  <p>'718042670591505846', '718042670591505792'</p>
  
  <p>Meanwhile, this query works:</p>
  
  <pre><code>SELECT 5002622390 + (5102 * 140737488355328) new_iid_hard_way,
     5002622390 + (5102 * CAST(POWER(2,47) AS UNSIGNED)) new_iid_CORRECT_way
  </code></pre>
  
  <p>It returns :
  '718042670591505846', '718042670591505846'</p>
  
  <p>My hunch is that it is a datatype overflow / wrapping issue... but even with Strict mode enabled on MySQL 5.6.15, I don't get any errors.</p>
  
  <p>Interestingly, sqlfiddle gets it wrong in all 4 cases:</p>
  
  <p><a href="http://sqlfiddle.com/#!9/d1bb6/1" rel="nofollow">http://sqlfiddle.com/#!9/d1bb6/1</a></p>
  
  <p>returning 718042670591505800</p>
  
  <p>Is this an overflow issue?  If yes, why isn't MySQL throwing an error when strict mode is enabled?</p>