Add binary search for closest value

Neither compile or run tested yet.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>