I need a decimal variant of ceiling
and floor
functions. Something like signif
with an option to choose in which direction to round.
For example, I need the number 2.63 to be transformed into 2.7, and not 3 (ceiling
) or 2.6 (signif(2.63,2)
).
The only solutions I can think of is to multiply by 10, then take ceiling
and divide back by 10.
ceiling(2.63*10)/10
I'm sure, there must be a more elegant solution.
My questions is quite similar to this one.