Rounding



On Jan 2, 2008 5:45 AM, Holger Schulz <qdl at gmx.net> wrote:

> I haven't found functions for rounding/truncating rational numbers
> yet. Are there some? How are they called?
>

ceiling: next largest integer
floor: next smallest integer
truncate: next integer closer to 0
round: nearest integer, preferring evens to odds for ties
   (if you want old-fashioned rounding, use floor(x+1/2) )

x          -5/3 -1/2 -1/3   0   1/2  3/2  5/2  8/3
ceiling     -1    0    0    0    1    2    3    3
floor       -2   -1   -1    0    0    1    2    2
truncate    -1    0    0    0    0    1    2    2
round       -2    0    0    0    0    2    2    3