frac is a function that returns the fractional part of a real number. The function can be formulated as You can't use 'macro parameter character #' in math mode\operatorname{frac} (x)=\begin{cases} x - \lfloor x \rfloor & x \ge 0 \\ x - \lceil x \rceil & x < 0 \end{cases} $$ [^1] ## In Shader Languages In shading languages, `frac` also work with vector values, in which case it will perform `frac` for each component. | Language | Function | Reference | | -------- | --------------- | -------------------------------------------------------------------------------------------------------------------------- | | GLSL | `fract(T) -> T` | [fract - OpenGL 4 Reference Pages](https://registry.khronos.org/OpenGL-Refpages/gl4/html/fract.xhtml) | | HLSL | `frac(T) -> T` | [frac - Win32 apps \| Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-frac) | [^1]: [Fractional part - Wikipedia](https://en.wikipedia.org/wiki/Fractional_part)