Calculate middle

Why is it better to calculate the midpoint c between a and b in the halving method with

c = a + (b - a) / 2.

instead of simple:

c = (a + b) / 2.

all variables are floating points.

+5
source share
1 answer

Any potential overflow / loss of precision in intermediate calculations should be avoided.

+6
source

All Articles