title: Why does C++ standard specify signed integer be cast to unsigned in binary operations with mixed signedness?
body: <p>The C and C++ standards stipulate that, in binary operations between a signed and an unsigned integer of the same rank, the signed integer is cast to unsigned. There are many questions on SO caused by this... let's call it strange behavior: <a href="https://stackoverflow.com/questions/5800946/unsigned-to-signed-conversion">unsigned to signed conversion</a>, <a href="https://stackoverflow.com/questions/17832815/c-implicit-conversion-signed-unsigned">C++ Implicit Conversion (Signed + Unsigned)</a>, <a href="https://stackoverflow.com/questions/3660901/a-warning-comparison-between-signed-and-unsigned-integer-expressions?rq=1">A warning - comparison between signed and unsigned integer expressions</a>, <a href="https://stackoverflow.com/questions/12877988/mod-with-mixed-signedness">% (mod) with mixed signedness</a>, etc.</p>
  
  <p>But none of these give any reasons as to why the standard goes this way, rather than casting towards signed ints. I did find a self-proclaimed guru who says it's the obvious right thing to do, but he doesn't give a reasoning either: <a href="http://embeddedgurus.com/stack-overflow/2009/08/a-tutorial-on-signed-and-unsigned-integers/" rel="noreferrer">http://embeddedgurus.com/stack-overflow/2009/08/a-tutorial-on-signed-and-unsigned-integers/</a>.</p>
  
  <p>Looking through my own code, wherever I combine signed and unsigned integers, I always need to cast from unsigned to signed. There are places where it doesn't matter, but I haven't found a single example of code where it makes sense to cast the signed integer to unsigned.</p>
  
  <p>What are cases where casting to unsigned in the correct thing to do? Why is the standard the way it is?</p>