isZero

0th

Percentile

Checks if a value is (close to) zero or not

Usage
## S3 method for class 'default}(x, neps=1, eps=.Machine$double.eps, ...)':
isZeroundefined

Checks if a value (or a vector of values) is (close to) zero or not
  where "close" means if the absolute value is less than neps*eps.
  Note that x == 0 will not work in all cases.

  By default eps is the smallest possible floating point value
  that can be represented by the running machine, i.e.
  .Machine$double.eps and neps is one.
  By changing neps it is easy to adjust how close to zero "close"
  means without having to know the machine precision (or remembering how
  to get it).

x{A vector of values.}
  eps{The smallest possible floating point.}
  neps{A scale factor of eps specifying how close to zero
     "close" means. If eps is the smallest value such that
     code{1 + eps != 1}, i.e. .Machine$double.eps, neps must
     be greater or equal to one.}
  ...{Not used.}

Returns a logical vector indicating if the elments are zero or not.

[object Object]

.Machine.

x <- 0
print(x == 0)      # TRUE
print(isZero(x))   # TRUE

x <- 1
print(x == 0)      # FALSE
print(isZero(x))   # FALSE

x <- .Machine$double.eps
print(x == 0)      # FALSE
print(isZero(x))   # FALSE

x <- 0.9*.Machine$double.eps
print(x == 0)      # FALSE
print(isZero(x))   # TRUE


logic
Aliases
  • isZero.default
  • isZero
Documentation reproduced from package R.utils, version 0.7.9, License: LGPL version 2.1 or newer (the releases)

Community examples

Looks like there are no examples yet.