title: Converting signed int to unsigned short with negative values being set to zero in C
body: <p>I would like to know if there is an efficient way of converting a signed integer to an unsigned short where negative integer values are simply set to 0 in the unsigned short (in C ANSI). I know that this can be done with a simple if statement like the following:</p>
  
  <pre><code>int val1;
  unsigned short val2;
  
  val1=-5; 
  if(val1&lt;0){
     val2=0;
  }else{
     val2=(unsigned short) val1;
  }
  </code></pre>
  
  <p>This conversion occurs very often in my program and the case <code>val1</code> is negative is very rare, so it seems like overkill to have this if statement occur every single time.</p>
  
  <p>Is there a more efficient way of making this conversion? </p>