## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup-------------------------------------------------------------------- library(discretes) ## ----------------------------------------------------------------------------- x <- arithmetic(representative = 0, spacing = 0.1) has_discretes(x, 0.3) has_discretes(x, 0.3, tol = 0) ## ----------------------------------------------------------------------------- v <- c(0, 0.1, 0.2, 0.1 * 3) # last entry is not exactly 0.3 has_discretes(v, 0.3) has_discretes(v, 0.3, tol = 0) ## ----------------------------------------------------------------------------- raw <- 10^(-5:5) raw preserved <- 10^as_discretes(-5:5) preserved ## ----------------------------------------------------------------------------- # Exponent slightly off from `5` q <- 10^(5 - 1e-10) # Error magnitude after transformation 10^5 - q ## ----------------------------------------------------------------------------- has_discretes(raw, q) has_discretes(preserved, q)