use binary search in valueAt:range: method.