# indefinite integration the result is -1 instead of $1 \over 2$

Below is from a book,

When 0 $\le$ x < 1, F(x) = $\int_0^x$ t dt = $x^2 \over 2$;

When 1 $\le$ x < 2, F(x) = $\int_0^1$ t dt + $\int_1^x$(2-t) dt = -$x^2 \over 2$ + $2x$ $\color{blue}{-1}$;

However, I think the last part of above in blue, the -1 should be $1 \over 2$, because
$\int_0^1$ t dt = F(1) - F(0) = $1^2 \over 2$ - 0 = $1 \over 2$,
$\int_1^x$(2-t) dt = $\int_1^x2$ dt - $\int_1^x$ t dt = $2x$ - $x^2 \over 2$

The problem is in your last integral: $$\int_1^x (2-t)dt = 2t - \frac{t^2}{2} \bigg|_1^x = \left( 2x-\frac{x^2}{2} \right) -\left( 2-\frac{1}{2} \right) = -\frac{x^2}{2} + 2x -\frac{3}{2}.$$ Then, we add the term $\int_0^1 t dt = \frac{1}{2}$, which yields that $$F(x) = \int_0^1 t dt + \int_1^x (2-t)dt = \frac{1}{2} + \left( -\frac{x^2}{2} + 2x -\frac{3}{2} \right) = -\frac{x^2}{2} + 2x -1.$$
$$\int_1^x\!2-t\,dt = \left[ 2t - \frac{t^2}{2}\right]_1^x = \left(2x - \frac{x^2}{2}\right) - \color{red}{\left(2 - \frac{1}{2}\right)}$$