Why prefer start + (end - start) / 2 over (start + end) / 2 when calculating the middle of an array?

后端 未结 4 1586
时光说笑
时光说笑 2020-11-29 17:02

I\'ve seen programmers use the formula

mid = start + (end - start) / 2

instead of using the simpler formula

mid = (start +          


        
4条回答
提交回复
热议问题