There are three expressions that as simple as they might seem, i do not truly understand how they work and how they are different from each other even when they seem to be basically the same thing.
Let's say we have two numbers $$$a$$$ and $$$b$$$ that represents two points on the number line the three expressions are $$$\frac{b+a}{2}$$$ , $$$\frac{|b-a|}{2}$$$ and $$$\frac{|b-a+1|}{2}$$$
The first expression is used to find the midpoint of the line segment determined by $$$b$$$ and $$$a$$$ and also when doing binary search you can also use it and it works. In the second expression , $$$|b-a|$$$ is normally used to find the distance between two points $$$a$$$ and $$$b$$$ so when you divide that distance by 2, is it not naturally for that to also for that to also determine the midpoint? since you are just taking the distance and dividing by two? The third expression was me just adding 1 to the second expression, to account for the lost digit from doing $$$|b-a|$$$ but non of those work in a binary search algorithm and i wonder why.
I know I'm dumb and i apologize for that, but can someone please help me understand? And this is making me feel like the $$$distance$$$ between two points is not the same as the $$$length$$$ of the segment determined by the two points.








