title: Hex Value Multiplication Overflow
body: <p>I am trying to multiply 2 Hex values together and receive a Hex value as an output.  I currently take a string that contains hex values, convert it to an integer to multiply, then convert it back to a hex string.</p>
  
  <p>This is an example of multiplying in decimal (base 10).</p>
  
  <pre><code>//this works for all cases
  //operand1, operand2 &amp; displayValue are strings that should be any value from 0-F
  long solutionInt = 0;
  int currentBase = 10;
  solutionInt = Integer.parseInt(operand1, currentBase) * Integer.parseInt(operand2, currentBase);
  displayValue = Integer.toString(Integer.valueOf(Long.toString(solutionInt)).intValue());
  </code></pre>
  
  <p>This is where I am having trouble, multiplying in hex (base 16)</p>
  
  <pre><code>//this does NOT work for larger numbers (that would overflow)
  //operand1, operand2 &amp; displayValue are strings that should be and value from 0-F               
  long solutionInt = 0;
  int currentBase = 16;           
  solutionInt = Integer.parseInt(operand1, currentBase) * Integer.parseInt(operand2, currentBase);
  displayValue = Integer.toHexString(Integer.valueOf(Long.toString(solutionInt)).intValue());
  </code></pre>
  
  <p>When multiplying by larger hex values that would cause an overflow (ie: 0xFFFFFFFF * 0xFFFFFFF), my android app crashes and I receive the following error:</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.IllegalStateException: Could not execute method of the activity
  </code></pre>
  
  <p>I need <code>displayValue</code> to hold a hex string that (if converted to a number) would be of size int.  I am not sure if there is some sort of overflow causing this error, or something else with an activity in android.</p>