16*((n+8)/16) is the formula you want if, in particular, you want to convert 8 to 16 (it is equally close to 0 to 16, so itβs impossible to decide how to convert it based solely on "near plural") concept, you have to decide! -), and, of course, sequentially from 24 to 32, from 40 to 48, etc. Use +7 instead of +8 if you prefer to convert 8 to 0 rather than 16 (and sequentially from 24 to 16, etc.).
To use generic X instead of hard-coded 16 , then the formula is X*((n+X/2)/X) (with the same condition as in the previous paragraph, if X even).
Edit : There is no need to bother with floating point numbers as other answers suggest, but you need to multiply back by X (which I mistakenly missed).
source share