modHalf

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

real
modHalf
(
real x
,
real y
)

Examples

static assert(0.modHalf(1) == 0);
static assert(0.5.modHalf(1) == 0.5);
static assert(1.modHalf(1) == 1);
static assert(1.5.modHalf(1) == -0.5);
static assert(2.modHalf(1) == 0);
static assert(2.5.modHalf(1) == 0.5);

Meta