Is object a scalar whole numeric
is_scalar_whole_numeric.RdReturns TRUE if x is a single integer, or a single double whose value is exactly equal to its truncated form.
See is_scalar_whole_number() to test for a scalar whole number within a chosen tolerance.
See base::is.integer() to test for integer storage type.
Details
Infand-Infin double storage returnTRUEbecauseInf == trunc(Inf).NAandNaNreturnFALSE.Zero-length input and
NULLreturnFALSE.Inputs with length other than
1returnFALSE.
Examples
#----------------------------------------------------------------------------
# is_scalar_whole_numeric() examples
#----------------------------------------------------------------------------
library(bkbase)
# TRUE
is_scalar_whole_numeric(1L)
#> [1] TRUE
is_scalar_whole_numeric(1)
#> [1] TRUE
is_scalar_whole_numeric(9.0)
#> [1] TRUE
is_scalar_whole_numeric(1e100)
#> [1] TRUE
is_scalar_whole_numeric(Inf)
#> [1] TRUE
# FALSE
is_scalar_whole_numeric(1.00000001)
#> [1] FALSE
is_scalar_whole_numeric(sqrt(2)^2)
#> [1] FALSE
is_scalar_whole_numeric(1 + 2^-30)
#> [1] FALSE
is_scalar_whole_numeric(c(1, 2, 3))
#> [1] FALSE
# Missing values and zero-length
is_scalar_whole_numeric(NA_integer_) # FALSE
#> [1] FALSE
is_scalar_whole_numeric(NA_real_) # FALSE
#> [1] FALSE
is_scalar_whole_numeric(NaN) # FALSE
#> [1] FALSE
is_scalar_whole_numeric(numeric(0)) # FALSE
#> [1] FALSE
is_scalar_whole_numeric(NULL) # FALSE
#> [1] FALSE