title: binary Search to find closest float value to target number
body: <p>I have some question and Maybe One of you can help me,
  I have a float array and I won't find the closest float value to the target number(float)</p>
  <p>I use a simple binary Search With javascript And from here I got stuck.</p>
  <pre><code>function binarySearch(arr, val, start = 0, end = arr.length - 1) {
      const mid = Math.floor((start + end) / 2);
  
      if(Math.abs(val - arr[mid]) &lt; Math.abs(val - arr[mid + 1])){
          return mid;
      }
  
      if (start &gt;= end) {
          return -1;
      }
  
      return val &lt; arr[mid]
          ? binarySearch(arr, val, start, mid - 1)
          : binarySearch(arr, val, mid + 1, end);
  }
  let array = [0,0.03336667683886884,0.06673335367773768,0.10010003051660653,0.13346670735547536,0.1668333841943442,0.20020006103321306]
  </code></pre>
  <p><code>let result = binarySearch(array,'0.166833')  //=&gt;  This value needs to be returned 0.1668333841943442</code></p>