When trying to calculate the length of the curve $r=1+\cos\theta$ whose graph is the following:

We need to evaluate $\int\limits_{0}^{\pi}\sqrt{r^2+(\frac{dr}{d\theta})^2}$, that is the following part starting at the point $(2,0)$
and then multiply by 2. Since $\int\limits_{0}^{2\pi}\sqrt{r^2+(\frac{dr}{d\theta})^2}=0$ I understand tat we cant do the whole thing at once since at the pole $(0,0)$ the curve has a sharp. But then trying to integrate $\int\limits_{\pi}^{3\pi}\sqrt{r^2+(\frac{dr}{d\theta})^2}=-8$ (in this interval the curve has no sharp) so I do not understand why do we get a negative value.
Now im getting more confused since if we try to calculate the lenght of the curve $r=2-2\cos\theta$

then we do can integrate over the whole interval $\int\limits_{0}^{2\pi}\sqrt{r^2+(\frac{dr}{d\theta})^2}=16$ without having any problems

Let $r=1+\cos(\theta)$, $\theta\in [0,2\pi]$. The length of the curve is given by
$$\begin{align} \int_0^{2\pi} \sqrt{r^2(\theta)+r'^2(\theta)}\,d\theta&=\int_0^{2\pi} \sqrt{(1+\cos(\theta))^2+(-\sin(\theta)^2)}\,d\theta\\\\ &=\int_0^{2\pi} \sqrt{2(1+\cos(\theta))}\,d\theta\\\\ &=\int_0^{2\pi} 2|\cos(\theta/2)|\,d\theta\\\ &=2\int_0^{\pi}\cos(\theta/2)\,d\theta-2\int_\pi^{2\pi}\cos(\theta/2)\,d\theta\\\\ &=8 \end{align}$$
Let $r=1-\cos(\theta)$, $\theta\in [0,2\pi]$. The length of the curve is given by
$$\begin{align} \int_0^{2\pi} \sqrt{r^2(\theta)+r'^2(\theta)}\,d\theta&=\int_0^{2\pi} \sqrt{(1-\cos(\theta))^2+(\sin(\theta)^2)}\,d\theta\\\\ &=\int_0^{2\pi} \sqrt{2(1-\cos(\theta))}\,d\theta\\\\ &=\int_0^{2\pi} 2|\sin(\theta/2)|\,d\theta\\\ &=2\int_0^{2\pi}\sin(\theta/2)\,d\theta\\\\ &=8 \end{align}$$