modulo

Modulo with result in \([0,m[\) interval.

Namespace: dsp

Prototype

T modulo(T x, T m)

Description

Contrary to the standard function fmod(x, m), which returns a value between \(-m\) and \(m\), this function returns a value between \(0\) and \(m\): \[ y = x + k\cdot m,\quad k\in\mathbb{Z},\ y\in \left[0,m\right[ \]

Example

let y = modulo(1.5, 1.0); // -> y = 0.5

See also

modulo_2π(), modulo_pm_π()