Get the position of x in vector y

binary_search_r(x, y, tol = sqrt(.Machine$double.eps))

Arguments

x

A numeric value

y

A numeric vector

tol

double equal tolerance

Value

A integer of the x position in y.

Examples

binary_search_r(2.5, 1:10)
#> [1] 3
binary_search_r(1.2, 1:10)
#> [1] 2
binary_search_r(0.5, 1:10)
#> [1] 1
binary_search_r(9.5, 1:10)
#> [1] 10
binary_search_r(11, 1:10)
#> [1] 11