I have a periodic function with fmod() like this (in C):
float f(float x) {
x = fmod(x, 1);
if (x < 0.5f) return 1 - x;
else return x
}
If I need a formal math formula for this function, what is the prettiest way?
Do people use fmod or mod functions in formulas like this? It looks strange.
$$ f(x) = \left\{ \begin{array}{**lr**} 1-\mathrm{fmod} (x,1), & 0 \leq \mathrm{fmod} (x,1) < 0.5 \\ \mathrm{fmod}(x,1), & 0.5 \leq \mathrm{fmod} (x,1) < 1 \end{array} \right. $$