I already know the basic rules for the both functions:

$$\text{Ceil}(2.5)=3\\ \text{Floor}(2.5)=2$$

But I could not understand the following these:

$$\text{Ceil}(2.6, 0.25)=2.75\\ \text{Floor}(2.6, 0.25)=2.5$$

Why is there a second parameter? How Could I calculate the that to obtain the results above?

PS: I already been researching on google and books, but I only could get what I already know.

Thanks for your collaboration.

  • 1
    $\begingroup$ It looks like the second parameter signifies the increments to which you're supposed to round to. For example, in Floor(2.6,0.25), you round 2.6 down to the nearest multiple of 0.25, which is 2.5. Another example: Floor($\pi$, 0.1) would be 3.1, because this is the nearest multiple of 0.1 to $\pi$. $\endgroup$ – shalop Apr 26 '15 at 0:27
  • $\begingroup$ Where did you get this from? It seems you are talking about the Ceil and Floor functions of some programing language, and in that case which programming language you are talking about certainly seems to be a significant piece of information useful for anyone who is trying to help you... Then again, you may be not talking about a programming language at all. Who knows! :-) $\endgroup$ – Mariano Suárez-Álvarez Apr 26 '15 at 0:30
  • $\begingroup$ If you do not tell us what you are talking about, we can only guess. Can you see the many ways in which this is not great? $\endgroup$ – Mariano Suárez-Álvarez Apr 26 '15 at 0:31
  • $\begingroup$ That does not tell us what you are talking about. $\endgroup$ – Mariano Suárez-Álvarez Apr 26 '15 at 0:34
  • $\begingroup$ You need to ask about that particular computer language... You are writing come computer language $Floor(2.6)$ and not mathematics $\lfloor 2.6 \rfloor$. So consult the manual for that language. $\endgroup$ – GEdgar Apr 26 '15 at 0:36

These are to the nearest multiple of $0.25$, rather than integer (multiple of $1$).


From the two examples you have, one possible interpretation is $$\text{Floor$(a,b)$ = Largest $x \leq a$ such that $x=nb$, where $n \in \mathbb{Z}$}$$ $$\text{Ceil$(a,b)$ = Smallest $x \geq a$ such that $x=nb$, where $n \in \mathbb{Z}$}$$ The usual floor and ceil function are $$\text{Floor(a) = Floor$(a,1)$}$$ $$\text{Ceil(a) = Ceil$(a,1)$}$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.