Hacker News new | ask | show | jobs
by jlokier 1290 days ago
Other comments point out that can overflow for some values.

However if you're doing mid-point in something like binary search where you already know y >= x AND x >= 0, then x + (y - x) / 2 is indeed a fine choice. It's a good one to remember.