4 ms·
This makes sure that none of the quantities being calculated will overflow while still returning the same answer. Where x is min and y is max, the midpoint is:
by siawyoung 6y ago
This makes sure that none of the quantities being calculated will overflow while still returning the same answer.
Where x is min and y is max, the midpoint is:
(x+y)/2 = x+(y-x)/2
x+y = 2x+y-x
x+y=x+y