Learn R Programming

assertive (version 0.2-6)

assert_all_numbers_are_whole_numbers: Is the input a whole number?

Description

Checks that the (probably floating point) input is a whole number.

Usage

assert_all_numbers_are_whole_numbers(x, tol = 100 * .Machine$double.eps)

assert_any_numbers_are_whole_numbers(x, tol = 100 * .Machine$double.eps)

assert_all_are_whole_numbers(x, tol = 100 * .Machine$double.eps)

assert_any_are_whole_numbers(x, tol = 100 * .Machine$double.eps)

is_whole_number(x, tol = 100 * .Machine$double.eps)

Arguments

x
Input to check.
tol
Differences smaller than tol are not considered.

Value

  • TRUE if the input is a whole number.

See Also

is_divisible_by

Examples

Run this code
# 1, plus or minus a very small number
x <- 1 + c(0, .Machine$double.eps, -.Machine$double.neg.eps)
# By default, you get a bit of tolerance for rounding errors
is_whole_number(x)
# Set the tolerance to zero for exact matching.
is_whole_number(x, tol = 0)

Run the code above in your browser using DataLab