public static int binarySearch(ArrayList<Double> arr, double target){
        int low = 0;
        int high = arr.size() - 1;

        if(target >= arr.get(high))
            return high;

        if(target <= arr.get(low))
            return low;

        while (low <= high){
            int mid = (low + high) / 2;
            double compare = arr.get(mid) - target;
            if(Math.abs(compare) < 0.01) return mid;
            else if(compare < 0) low = mid;
            else high = mid;

            if(high - low == 1) break;
        }

        return low;
    }