Hey,
I see you've already seen my bugged version of the codeI thought it was done, but I didn't test it too well. Here's a working version (atleast I think
), but I haven't tested it with negative values though. I suggest you use this code as it's easier to read and to adjust for use with negative values.
code:
var srtN = 23;
var oldN = 234;
var newN;
//--
if (oldN%srtN<srtN/2) {
newN = oldN-(oldN%srtN);
} else {
newN = oldN-(oldN%srtN)+srtN;
}
trace(newN);
SaphuA




I thought it was done, but I didn't test it too well. Here's a working version (atleast I think
), but I haven't tested it with negative values though. I suggest you use this code as it's easier to read and to adjust for use with negative values.
Reply With Quote