public static int search ( float [ ] floatArray , float value ) { int start = 0 ; int end = floatArray . length - 1 ; int middle = 0 ; while ( start <= end ) { middle = ( start + end ) >> 1 ; if ( value == floatArray [ middle ] ) { return middle ; } if ( value < floatArray [ middle ] ) { end = middle - 1 ; } else { start = middle + 1 ; } } return - 1 ; }
Search for the value in the sorted float array and return the index .