Java examples for Collection Framework:Array Search
binary search double array
public class Main{ public static int binsearch(double[] xs, double x) { int lo = 0, hi = xs.length - 1; while (hi - lo > 1) { final int mid = midpoint(lo, hi); if (xs[mid] <= x) { lo = mid;/*from w w w . j a va 2 s . c om*/ } else { hi = mid; } } return lo; } public static int midpoint(int lo, int hi) { return lo + (hi - lo) / 2; } }