How to show that the function $f(x) = \{x\}$ is continuous? I'm working through Spivak's Calculus and I'm currently reading chapter 24 discussing uniform convergence. In the text the following example was used to illustrate the Weirstrauss M-Test:

A few sentences down it is established that the infinite series is also continuous. Which got me to thinking.....Through the visual example I can see that $f(x) = \{x\}$ is continuous, but I was wondering to myself how could I show formally that this is the case. The ideas that came to my head are either the function is a composition of continuous functions, which I could then clearly see that the function is also continuous or I would have to prove it through the $\epsilon$ - $\delta$ method. I feel that there should be a composition that can be used. But in order to do that I have to rewrite the function $f(x) = \{x\}$. The following was my attempt:
$$f(x) = \{x\} =  
\begin{cases}
|x - \lfloor x \rfloor | & x < \lfloor x \rfloor + \frac{1}{2} \\
|x - \lceil x \rceil  | & x > \lceil x \rceil - \frac{1}{2} \\
\end{cases} $$
Where $\lfloor x \rfloor$ is the floor function and $\lceil x \rceil$ the ceiling function.
I'm not sure if this is correct, but would like some feedback on it.
 A: I think you have a typo: the second case of $f$ should be $x\gt\lceil x\rceil -1/2$. Also, you need one of the two cases to include the half integers, doesn't matter which. (I'll take wlog the first case to be $\leq$)
Do note that your definition of $f$ is different from the usual fractional part function $x\mapsto \{x\}$ (for eg, $f(5.6)=0.4$ but $\{5.6\}=0.6$)
Your $f$ is a simple linear map on the intervals $(k,k+1/2)$ and $(k+1/2,k+1)$ for all integers $k$, so continuity there is obvious.
All that's left to do is to check continuity at the integers and half-integers, ie, numbers of the form $n+1/2$ for integer $n$
For $n\in\Bbb Z$, we note that $$\lim_{k\to n^+}f(k)=\lim_{k\to n^-}|k-\lfloor k\rfloor|=|n-n|=0\\ \lim_{k\to n^-}f(k)=\lim_{k\to n^-}|k-\lceil k\rceil|=|n-n|=0\\f(n)=0$$
and
$$\lim_{k\to (n+1/2)^+}f(k)=\lim_{k\to (n+1/2)^+}|k-\lceil k\rceil|=|(n+1/2)-(n+1)|=1/2\\ \lim_{k\to (n+1/2)^-}f(k)=\lim_{k\to (n+1/2)^-}|k-\lfloor k\rfloor|=|(n+1/2)-n|=1/2\\f(n+1/2)=|(n+1/2)-\lfloor(n+1/2)\rfloor|=|(n+1/2)-n|=1/2$$
