Java - Arrays.binarySearch function equivalent in awk

Hi all

Does anyone know Java-Arrays.binarySearch function equivalent in awk
I tried like this but it's not correct one,it just returns array index if and only when searched value available in array, for some reason if searched value not found then I want to return upper nearest neighbour index. please let me know if anyone have better idea

function Arrays_binarySearch(arr,val){
                    
                    for(b in arr){
                    if(arr==val)
                             return b
                             break
                             }    
                    
                     }

here is link to example in java

Java.util.Arrays.binarySearch(int[] a, int key) Method Example

please someone help me..

Check out this info there are examples for multiple languages:
Binary search - Rosetta Code