using binary search method to get the range of the given num