[Math] How to express rounding down/up to nearest multiplum of a number

notation

I've written an equation in a programming language which I need to express using maths:

slots = (elements_count – (elements_count % slot_size) + slot_size) / slot_size

In Excel, you can also write (replaced cell names):

=(FLOOR.PRECISE(elements_count;slot_size)+slot_size)/slot_size

I've changed the story and variable names for the purpose of this question, but let's say the equation is used to figure out how many slots of size slot_size we need to fit elements_count elements.

The modulus is used to round up to the nearest whole number divisible with slot_size. The division then converts this to number of slots. It is correct that the result is 1 when there are zero elements.

How can I express this in mathematical notation? Is there a syntax to round up or down to the nearest number divisible with another number?

Best Answer

Usually, in mathematical notation we express rounding down with the floor function so $\lfloor a \rfloor$ is the largest integer less than or equal to $a$. Similarly, for rounding up, we use the ceiling function, so $\lceil a \rceil$ is the smallest integer greater than or equal to $a$. So for the rounded-down division of $a$ by some $b$, we would just write $\lfloor\frac{a}{b}\rfloor$. Similarly for rounding up you get $\lceil\frac{a}{b}\rceil$.


Edit: For the expression in the question, we can denote it as $\frac{e - e\%s + s}{s} = \frac{e - e\%s}{s} + 1 = \lfloor\frac{e}{s}\rfloor + 1$.