ID:165253
 
How do I make a ceil proc where I can specify the ceiling?

For example:

ceil(4, 8) = 8
ceil(9, 8) = 16


[edit]
Blargh.

I also need a floor proc that I can specify the floor of =/

For example:

floor(6, 4) = 4
floor(11, 4) = 8
floor(13, 4) = 12

Get it? =/
You basically have to find the distance to the nearest multiple you want. You can use the module operator for that.

proc/floor(val, mod)
return val - val % mod

proc/ceil(val, mod)
return val + val % mod