eps <- .Machine$double.eps
zero_range(c(1, 1 + eps)) # TRUE
zero_range(c(1, 1 + 99 * eps)) # TRUE
zero_range(c(1, 1 + 101 * eps)) # FALSE - Crossed the tol threshold
zero_range(c(1, 1 + 2 * eps), tol = eps) # FALSE - Changed tol
# Scaling up or down all the values has no effect since the values
# are rescaled to 1 before checking against tol
zero_range(100000 * c(1, 1 + eps)) # TRUE
zero_range(100000 * c(1, 1 + 200 * eps)) # FALSE
zero_range(.00001 * c(1, 1 + eps)) # TRUE
zero_range(.00001 * c(1, 1 + 200 * eps)) # FALSE
# NA values
zero_range(c(1, NA)) # NA
zero_range(c(1, NaN)) # NA
# Infinite values
zero_range(c(1, Inf)) # FALSE
zero_range(c(-Inf, Inf)) # FALSE
zero_range(c(Inf, Inf)) # TRUE
Run the code above in your browser using DataLab