php % (mod function) goes to negative on large numbers. How to get rid of it?
<p>How do I use % properly not to get negative result?</p>

<pre><code>&lt;?php 
    $x = 1103515246*12345;
    echo $x." ".decbin($x)."&lt;/BR&gt;";
    $y = $x % (1 &lt;&lt; 15);
    echo $y." ".decbin($y)."&lt;/BR&gt;";
?&gt;
</code></pre>

<p>Output:</p>

<pre><code>13622895711870      11010011110111000001011001111110

-27010              11111111111111111001011001111110
</code></pre>

<p>RESOLVED</p>

<p><code>$y = bcmod($x,(1 &lt;&lt; 15));</code> Solves the issue. Thank you for quick help! It was my first question!</p>
