Hi,

I want to find the index of 2 values A and B in a large array, from an input X, with the following conditions:

- the array will have values in an increasing order, and the values are all ints.

- the spacing of the values in the array is unknown

- X will be an input in the range of coverage of the array.

- A will be the closest number to X such that A < X

- B will be the closest number to X such that B > X

- if X is exactly equal to a number in the array, the index of that number will be returned.

I sort of know how to code this in arduino, but I was wondering what is the most efficient way and less clock cycles as possible way to do this...

Thanks