R/get_decimals.R

Defines functions get_decimals

get_decimals <- function(x) {
  if ((x %% 1) != 0) {
    # if (abs(x - round(x)) > .Machine$double.eps^0.5) {
    nchar(strsplit(sub("0+$", "", format(x, scientific = FALSE)), ".", fixed = TRUE)[[1]][[2]])
  } else {
    return(0)
  }
}

Try the SSNbler package in your browser

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

SSNbler documentation built on Sept. 30, 2024, 9:44 a.m.