Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- is.integer(66) # FALSE
- is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol
- is.wholenumber(1) # is TRUE
- check.integer <- function(x) {
- x == round(x)
- }
- x%%1==0,
- min(abs(c(x%%1, x%%1-1))) < tol,
- all.equal(a, as.integer(a))
- testInteger <- function(x){
- test <- all.equal(x, as.integer(x), check.attributes = FALSE)
- if(test == TRUE){ return(TRUE) }
- else { return(FALSE) }
- }
- check.integer <- function(N){
- !grepl("[^[:digit:]]", format(N, digits = 20, scientific = FALSE))
- }
- check.integer(3243)
- #TRUE
- check.integer(3243.34)
- #FALSE
- check.integer("sdfds")
- #FALSE
- > check.integer(222e3)
- [1] TRUE
- > 2/49*49
- [1] 2
- > check.integer(2/49*49)
- [1] FALSE
- > is.wholenumber(2/49*49)
- [1] TRUE
- > is.integer(66L)
- [1] TRUE
- > is.wholenumber(1+2^-50)
- [1] TRUE
- > check.integer(1+2^-50)
- [1] FALSE
- all(floor(x) == x, na.rm = TRUE)
- testInteger <- function(x){
- test <- all.equal(x, as.integer(x), check.attributes = FALSE)
- }
- print(testInteger(2/49*49))
- [1] "Mean relative difference: 0.5"
- as.integer(2/49*49)
- [1] 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement