Say I got a set of 10 random numbers between 0 and 100.
An operator gives me also a random number between 0 and 100. Then I got to find the number in the set that is
Someone tagged this question Mathematica, so here's a Mathematica answer:
set = {1,10,34,39,69,89,94,96,98,100}; opno = 45; set[[Flatten[ Position[set - opno, i_ /; Abs[i] == Min[Abs[set - opno]]]]]]
It works when there are multiple elements of set equally distant from the operator number.