Consider a random variable $X$ with distribution function $F(x)$. Calculate the $r$th moment of $X$, $\mathbb E X^r$. I read that the desired moment can be calculated as follows.
$$ \begin{align} \mathbb E X^r &= \int_0^\infty x^r dF(x) - \int_0^\infty (-x)^r dF(-x) \\[5pt] &=r \int_0^\infty x^{r-1} \left[ 1-F(x)+(-1)^rF(-x) \right] dx. \end{align} $$
Could anyone explain to me why this is true, please? In addition, when do we need to find the moments in this way? Thank you!