Here you can find the source of binarySearch(double values[], double search)
public static int binarySearch(double values[], double search)
//package com.java2s; //License from project: Apache License public class Main { public static int binarySearch(double values[], double search) { int min = 0, max = values.length; int index = max / 2; while (max - min > 1) { if (values[index] == search) { return index; }/* w w w .j a v a 2 s.c o m*/ if (values[index] < search) { min = index; } else { max = index; } index = (max + min) / 2; } if (values[index] < search) { index++; } return index; } }