Is there an idiomatic way to round to the nearest multiple of a number, short of rounding both up and down and seeing which one is closest?
Assume o
I've answered this before on Rounding off a number to the next nearest multiple of 5
With using cmath::abs
cmath::abs
int rounded = n + abs((n % denom) - denom);
You can change denom with any denomination you want
denom