Is something like this what you need?
http://avisynth.nl/index.php/Internal_functions#Floor
Code:
function MakeMod2(int myInt, int "Rounding") {
# round to nearest integer = 1
# round down = 2
# round up = 3
# round towards zero = any integer other than 1, 2 or 3
rounding = default(rounding, 1)
myFloat = float(myInt)
Mod2Out = \
(rounding == 1) ? round(myFloat / 2.0) * 2 : \
(rounding == 2) ? floor(myFloat / 2.0) * 2 : \
(rounding == 3) ? ceil(myFloat / 2.0) * 2 : \
int(myFloat / 2.0) * 2
return Mod2Out }
For mod4 it'd be
round(myFloat / 4.0) * 4
etc.
Or something similar.
http://avisynth.nl/index.php/Operators
I think Mod (%) works much the same way as FMod, but FMod needs float values.
http://avisynth.nl/index.php/Internal_functions#Fmod
Code:
function MakeMod2(int myInt, bool "RoundUp") {
RoundUp = default(RoundUp, false)
Mod2Out = \
(myInt % 2 == 0) ? myInt : \
!RoundUp ? myInt - 1 : \
myInt + 1
return Mod2Out }