title: Java 8 Unsigned Integer Addition and Potential Overflow
body: <p>I'm working exercises from the book "Java SE 8 for the Really Impatient" by Cay S. Horstmann. One of the exercises based on the improvements in the <code>Number</code> classes asks:</p>
  
  <blockquote>
    <p>Write a program that adds, subtracts, divides, and compares numbers
    between 0 and 2<sup>32</sup> - 1, using <code>int</code> values and unsigned
    operations. Show why <code>divideUnsigned</code> and <code>remainderUnsigned</code> are
    necessary.</p>
  </blockquote>
  
  <p>The problem is, if you add 2 unsigned ints, the sum may overflow the integer limit. I don't see a way to prevent that without using a long to store the sum and checking if it's greater than <code>Integer.MAX_VALUE</code>. Is it possible to do this using ints only?</p>