As it turns out, Combinatorica has the function BinarySearch[] implemented. The code in the package is attributed to Paul Abbott. What follows is a modification of the routine that gives results in the format desired by the OP:
bisect[k_?NumericQ, l_List] :=
Block[{n = Length[l], lo, mid, hi, el},
{lo, hi} = {1, n};
While[lo <= hi,
If[(el = l[[mid = Quotient[lo + hi, 2]]]) === k,
Which[
mid == 1,
Return[{{-Infinity, First[l]}, Take[l, 2]}],
mid == n,
Return[{Take[l, -2], {Last[l], Infinity}}],
True,
Return[Partition[Take[l, mid + {-1, 1}], 2, 1]]]];
If[el > k, hi = mid - 1, lo = mid + 1]
];
Which[
lo == 1,
Return[{-Infinity, First[l]}],
lo == n + 1,
Return[{Last[l], Infinity}],
True,
Return[l[[{lo - 1, lo}]]]
]
] /; VectorQ[l, NumericQ]
I'll leave to you how to handle the case of the singleton list.
fifxis an element oflist? – J. M.♦ Jan 21 '12 at 10:16{{-∞,x},{x,∞}}– Prashant Bhate Jan 21 '12 at 10:26