R/is.wholenumber.R

Defines functions is.wholenumber

Documented in is.wholenumber

### Test for whole number, with tolerance for representation
### From post by Tony Plate <tplate_at_acm.org>
is.wholenumber <- function(x, tolerance = .Machine$double.eps^0.5) {
  if (!is.numeric(x)) {
    return(FALSE)
  } else {
    return(isTRUE(all(abs(x - round(x)) < tolerance)))
  }
}

Try the DistributionUtils package in your browser

Any scripts or data that you put into this service are public.

DistributionUtils documentation built on May 2, 2019, 4:46 p.m.