How to convert any integer to mod2
I compute an integer in a script and integer can be any value. But I need to modify it so that it is mod2 (evenly divisible by 2). How can we do that? (I've hunted but not found anything.) Will I have to write a custom function just to do that? (And I'm not sure yet whether I want to round up or down, or round closer to zero or farther--one step at a time, ha ha.)
Edit: IF we have to have a function, would this do it?
function MakeMod2(int myInt)
{
bitRshift(myInt,1)
bitLshift(myInt,1)
return myInt
}
Last edited by TCmullet; 22nd September 2019 at 07:56.
|