code: private int calculateClosest(float base, float[] others) {
  
          int result = -1;
          float bestMatch = Float.MAX_VALUE;
          for (int count = 0; count < others.length; count++) {
              float difference = Math.abs(base - others[count]);
              if (difference < bestMatch) {
                  // new best match found
                  bestMatch = difference;
                  result = count;
              }
              if (bestMatch == 0f) {
                  // it does not get better then this
                  break;
              }
          }
          return result;
      }
docs: Calculate the closest match of the given base float with the list of others.<p>
  
  @param base the base float to compare the other with
  @param others the list of floats to compate to the base
  
  @return the array index of the closest match