2 ms·
min + (max - min) / 2 Edit: never mind, this can overflow too
by baobabKoodaa 4y ago
min + (max - min) / 2
Edit: never mind, this can overflow too
- stephencanon 4y agoFortunately the cases where this might overflow (a and b have opposite sign) are precisely the cases where the naive (a+b)/2 is guaranteed to work. So put them together to get a suboptimal but perfectly fine solution.