In every code piece I read online or on book, say if someone wants to compute the midpoint between s and e, they do:
int mid = s + ((e - s) / 2);
Mathematically isn't this the same thing as
int mid = (s + e) / 2;
So why is it written in the first way often? My guess is to prevent integer overflow but not sure.
Thanks