title: Overflow/underflow in unsigned numbers
body: <p>So, if you have a carry out of 1 on addition with unsigned numbers, you have overflowed, and if you have a carry out of 0 with subtraction, you have underflowed. Does this work in every case, though?</p>
  
  <p>If you do 5-0:
  0101
  -0000</p>
  
  <p>= 
  0101
  +(1111 + 1)</p>
  
  <p>=
  0101
  +0000</p>
  
  <p>= 0101... there is a carry out of zero here, instead of 1. How does one account for this case? Is there a different way to do it?</p>
  
  <p>(using MIPS architecture, or anything else)</p>
  
  <p>---Edit</p>
  
  <p>Thanks Amadan. I understand that part, though.  My problem is just that zero seems to be a special case.  It does not seem to follow what normal numbers do: in my example above, there is no carry out of 1.</p>
  
  <p>I'm doing circuit design working with an ALU at the moment and trying to implement the overflow detection, when this one case came up that doesn't follow what the others do.</p>
  
  <p>We are assuming that with subtraction, the second operand is preinverted (twos complement) before going into the ALU (then added to the first operand).  So, whenever the "invert_b" for subtraction is set to 1, b is inverted and we assume that the case we are checking for is subtraction, which should have a carry out of 1.</p>