@mahidasp In your example, you will visit both 2 and 3, so whichever is closer will be the answer. If you are coming from 2, you will go right to 3, because target > 2, and if you are coming from 3, you will go left to 2 because target < 3.
Ahaha, I forgot I had thought of a different fix before I went to sleep last night, one that some of my solutions (unintentionally) already use :-) (and caikehe's third does, too). In case of a distance-to-target tie between previous closest value and new value (lower in the tree), simply prefer the new value, not the previous. That way, if the target is very large, the result will still be correct. Works for large negative target as well.
So yeah, that's actually quite neat and doesn't require such an ugly additional fix, so I'm now less against large targets :-)