<a href="http://petsc.cs.iit.edu/petsc/petsc-dev/rev/6eccf13462a8">http://petsc.cs.iit.edu/petsc/petsc-dev/rev/6eccf13462a8</a><div><br></div><div>Since when did we start using assert()?</div><div><br></div><div>When we discussed this in chat, I specifically asked you to use</div>
<div><br></div><div>PetscInt imid = imin + (imax - imin)/2;</div><div><br></div><div>but then you went off and wrote this crap</div><div><br></div><div>PetscInt imid = (imin+imax)/2;</div><div><br></div><div>which overflows prematurely. <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html">http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html</a></div>
<div><br></div><div>Your implementation also does unnecessary arithmetic, but due to possible overflow, the compiler may not be able to remove it. Why not use the tight structure I suggested?</div>