Okay, I wanted to know if anyone knows how to create a formula that rounds a number off to the nearest variable. Note, that I am not trying to round the number to the nearest integer but to the nearest mulitple of a variable here are some examples:
code:
var staticNum = 42;
var changingNum = 35;
now I want to round changingNum to the nearest multiple of staticNum.
In this case I want changingNum to equal 42. How do I do it? Then how would I do it this way:
code:
var changingNum = 86;
In this case, I want changingNum to equal 84, because 84 is the nearest multiple of 42. Please help. If you don't understand what I mean, ask questions because I will be happy to answer.




Reply With Quote