Will a long % int will always fit into an int
<p>Can anyone confirm if this is true? </p>

<p>Java will turn a <code>long</code> % <code>int</code> into a <code>long</code> value.  However it can never be greater than the modulus to it is always safe to cast it to an <code>int</code>.</p>

<pre><code>long a = 
int b =
int c = (int) (a % b); // cast is always safe.
</code></pre>

<p>Similarly a <code>long</code> % <code>short</code> will always be safe to cast to a <code>short</code>.</p>

<p>If true, does any one know why Java has a longer type for <code>%</code> than needed?</p>

<p>Additionally, there is a similar case for <code>long</code> &amp; <code>int</code> (if you ignore sign extension)</p>
