compareFloat: Compare values to floating-point precision

compareFloatR Documentation

Compare values to floating-point precision

Description

These functions compare values while accounting for differences in floating point precision.

Usage

compareFloat(x, y, op, tol = .Machine$double.eps^0.5)

x %<% y

x %<=% y

x %==% y

x %>=% y

x %>% y

x %!=% y

Arguments

x, y

Numeric

op

Operator for comparison (must be in quotes): "<", ">", "<=", ">=", "==", or "!="

tol

Tolerance value: The largest absolute difference between x and y that is to be considered equality. The default is .Machine$double.eps^0.5.

Value

TRUE, FALSE, or NA

Examples

x <- 0.9 - 0.8
y <- 0.8 - 0.7

x < y
x %<% y
compareFloat(x, y, "<")

x <= y
x %<=% y
compareFloat(x, y, "<=")

x == y
x %==% y
compareFloat(x, y, "==")

y > x
y %>% x
compareFloat(y, x, ">")

y >= x
y %>=% x
compareFloat(y, x, ">=")

x != y
x %!=% y
compareFloat(x, y, "!=")


omnibus documentation built on Sept. 17, 2024, 5:09 p.m.