title: How To Avoid Integer Overflow through Multiplication without Typecasting?
body: <p>Please consider the following code:</p>
  
  <pre><code>unsigned int var1 = 4294967295;
  
  unsigned int var2 = 1000000;
  
  unsigned int var3;
  
  var3 = some_expression - (var1*var2)/some_expression;
  </code></pre>
  
  <p><strong>Bug:</strong></p>
  
  <p>In the expression for var3, the value:</p>
  
  <p>(var1*var2) is being truncated to a 32-bit Integer (since it is obtained by multiplying 2 32-bit Integers).</p>
  
  <p><strong>Possible Fix:</strong></p>
  
  <pre><code>var3 = some_expression - ((unsigned long int)var1*var2)/some_expression;
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p><strong>Solaris</strong> does <strong><em>NOT</em></strong> accept this typecasting &amp; throws the following error:</p>
  
  <p><em>"conversion to non-scalar type requested"</em></p>
  
  <p>Can I fix this issue without typecasting?</p>