public class BinarySearch
{
   public static int search (int pForThis, int[] pInThis)
   {
           int     high, low, mid;

       // Set up bounds
       high = pInThis.length;
       low  = -1;

       // Bounce around array
       while (high - low > 1) {
           // Find the mid-point (taking care of integer wrap-around)
           mid = (high + low) >>> 1;
           // Adjust the range
           if (pInThis [mid] > pForThis) {
               high = mid;
           } else {
               low  = mid;
           }
       }

       // Check if we've found the value while taking care of edge conditions
       if (low == -1 || pInThis[low] != pForThis) {
           // Nope - signal "not found"
           return -1;
       }

       // Found! Return postion.
       return low;
   }
}


