Problem:
ceiling(31)
ceiling(31/60*60)
What is the correct way to fix such errors?
Doing multiplication before division is not an option; my code looks something like this:
x <- 31/60
...
y <- ceiling(x*60)
I am going to make a new function:
ceil <- function(x) {
ceiling(signif(x))
}
But I'm new to R, maybe there is a better way.
UPDATE
Sorry, I did not provide more details, I have the same problem in different parts of my code for various reasons, but always with a ceiling.
I am aware of a rounding error in floating point calculation. Perhaps the title of the question can be improved. I do not want to correct the inaccuracy of the ceiling function , what I want to do, maybe, on the contrary, make the ceiling less accurate. A way to tell R to ignore numbers that clearly sound:
options(digits=17)
31/60*60
, -, , , .