title: Implicit conversion of unsigned char (arithmetic conversion vs. assignment)
body: <p>In am working on something and came across code similar to the following:</p>
  
  <pre><code>#define MODULUS(a,b)        ((a) &gt;= 0 ? (a)%(b) : (b)-(-a)%(b))
  
  unsigned char w;
  unsigned char x;
  unsigned char y;
  char z;
  
  /* Code that assigns values to w,x and y.  All values assigned 
     could have been represented by a signed char. */
  
  z = MODULUS((x - y), w);
  </code></pre>
  
  <p>It is my understanding that the arithmetic <code>(x - y)</code> will be accomplished prior to any type conversion and the macro will always evaluate to <code>(a)%(b)</code> -- as the result will be an unsigned char which is always greater than or equal to zero.  However, the code functions as intended and I think that my understanding is flawed.  So...</p>
  
  <p>My questions are these:</p>
  
  <ol>
  <li><p>Does an implicit type conversion to signed char occur before the expression is evaluated?</p></li>
  <li><p>Is there a situation (for example, if the unsigned values were large enough that they could not be represented by a signed value) where the above code would not work?</p></li>
  </ol>