Is object a scalar whole number
is_scalar_whole_number.RdReturns TRUE if x is a single whole number to some tolerance.
See is_scalar_whole_numeric() to test for a scalar whole number without a tolerance.
See base::is.integer() to test for integer storage type.
Details
NA,NaN,Inf, and-InfreturnFALSE.Zero-length input and
NULLreturnFALSE.Inputs with length other than
1returnFALSE.
Examples
#----------------------------------------------------------------------------
# is_scalar_whole_number() examples
#----------------------------------------------------------------------------
library(bkbase)
# TRUE
is_scalar_whole_number(1L)
#> [1] TRUE
is_scalar_whole_number(1)
#> [1] TRUE
is_scalar_whole_number(9.0)
#> [1] TRUE
is_scalar_whole_number(sqrt(2)^2)
#> [1] TRUE
is_scalar_whole_number(1 + 2^-30)
#> [1] TRUE
is_scalar_whole_number(1e100)
#> [1] TRUE
is_scalar_whole_number(1.00000001)
#> [1] TRUE
# FALSE
is_scalar_whole_number(1.0000001)
#> [1] FALSE
is_scalar_whole_number(Inf)
#> [1] FALSE
is_scalar_whole_number(c(1, 2, 3))
#> [1] FALSE
# Missing values and zero-length
is_scalar_whole_number(NA_integer_) # FALSE
#> [1] FALSE
is_scalar_whole_number(NA_real_) # FALSE
#> [1] FALSE
is_scalar_whole_number(NaN) # FALSE
#> [1] FALSE
is_scalar_whole_number(numeric(0)) # FALSE
#> [1] FALSE
is_scalar_whole_number(NULL) # FALSE
#> [1] FALSE