The correct way most people would write this for positive integers is:
if (a < b)
return a + (b - a) / 2;
else return b + (a - b) / 2;
This method is just more efficient (for places where it matters) as it avoids divisions and branches. But for a vast, vast majority of use-case that tiny efficiency gain doesn’t really matter.