 <p>You are overflowing the max value that can be stored in an int which is 2,147,483,647.</p> <p>When calculating the numerator in your equation you are doing ((39258-0)*(99999-0)) which is 3,925,760,742. </p> <p>If you change it to this you won't have this issue:</p> <pre><code>long numerator = (long)(toFind - sortedArray[low]) * (long)(high - low); mid = low + numerator / (sortedArray[high] - sortedArray[low]); </code></pre> <p>I think you also need to change your while loop to be:</p> <pre><code>while (sortedArray[low] &lt; toFind &amp;&amp; sortedArray[high] &gt;= toFind) { </code></pre> <p>Otherwise you have a situation where sortedArray[low] == sortedArray[high] == toFind</p> <p>Then your equation reduces to</p> <pre><code>mid = low + (0 * (high - low)) / 0 = 0/0 </code></pre> <p>Java allows division by zero. I'm not exactly sure what happens though, it may be that in this case mid = infinity or NaN.</p>