modHalf

reduce x into [-y .. y] modulo 2y.

real
modHalf
(
real x
,
real y
)

Examples

1 static assert(0.modHalf(1) == 0);
2 static assert(0.5.modHalf(1) == 0.5);
3 static assert(1.modHalf(1) == 1);
4 static assert(1.5.modHalf(1) == -0.5);
5 static assert(2.modHalf(1) == 0);
6 static assert(2.5.modHalf(1) == 0.5);

Meta