How to tackle the following integration problem I am stuck on the following problem from an exercise in my analysis book: 

Show that $$\int_0^4 x \mathrm d(x-[x])=-2$$ where $[x]$ is the greatest integer not exceeding $x$. 

I think I have to partition the interval $[0,4]$ into some suitable subintervals and here I see $x-[x] \ge 0$. 
But, I am not sure how to tackle it as no similar types of problems has been discussed in the book. Can someone explain? Thanks and regards to all.
 A: Using integration by parts for the Riemann-Stieltjes integral, we get:
$$\int\limits_0^4xd(x-\lfloor x\rfloor)=\left.x(x-\lfloor x\rfloor)\right|_{x=4}-\left.x(x-\lfloor x\rfloor)\right|_{x=0}-\int\limits_0^4(x-\lfloor x\rfloor)dx=$$
$$=4(4-4)-0(0-0)-\int\limits_0^4 x\,dx+\int\limits_0^4\lfloor x\rfloor dx=$$
$$=\left.-\frac12x^2\right|_0^4+\int\limits_0^1 0\cdot dx+\int\limits_1^21dx+\int\limits_2^32dx+\int\limits_3^43dx=-8+1+2+3=-2$$
A: You can define $u=x-[x]$, which will make the $d(x-[x])$ much more friendly.  Then $x=u+[x]$ and it seems natural to split the integral into $[0,1],[1,2],[2,3],[3,4]$  On each interval you can see what to do with the $[x]$.  That said, I am not getting $\frac 32$ for an answer.
A: If we let $f(x) = x -\lfloor x \rfloor$, then the Lebesgue Stieltjes measure corresponding to $f$ can be written as $\mu_f = m -\sum_n \delta_n$, where $m$ is the Lebesgue measure and $\delta_n$ is the Dirac measure concentrated at $n$.
Then $\int_0^4 x d \mu_f = \int_0^4 xdx - \int_0^4 x d(\sum_n \delta_n) = 8-(0+1+2+3+4) = -2$.
A: What happens if you try partitions like
$$
0,1-\delta,1,2-\delta,2,3-\delta,3,4-\delta,4
$$
where $\delta>0$ is very small?
