MPFR Number Utilities
mpfrVersion()
returns the version of the MPFR library which
Rmpfr is currently linked to.
mpfrIs0(.)
uses the MPFR library in the documented way to
check if (a vector of) MPFR numbers are zero. It was called
mpfr.is.0
which is strongly deprecated now.
.mpfr.is.whole(x)
uses the MPFR library in the documented way to
check if (a vector of) MPFR numbers is integer valued. This is
equivalent to x == round(x)
, but not at all to
is.integer(as(x, "numeric"))
.
You should typically rather use (the "mpfr"
method of the
generic function) is.whole(x)
instead.
The former name mpfr.is.integer
is deprecated now.
mpfrVersion() mpfrIs0(x) ## S3 method for class 'mpfr' c(...) ## S3 method for class 'mpfr' diff(x, lag = 1L, differences = 1L, ...)
x |
an object of class |
... |
for |
lag, differences |
for |
mpfrIs0
returns a logical vector of length length(x)
with values TRUE
iff the corresponding x[i]
is an MPFR
representation of zero (0
).
Similarly, .mpfr.is.whole
and is.whole
return a
logical vector of length length(x)
.
mpfrVersion
returns an object of S3 class
"numeric_version"
, so it can be used in comparisons.
The other functions return MPFR number (vectors), i.e., extending
class mpfr
.
The class description mpfr
page mentions many
generic arithmetic and mathematical functions for which "mpfr"
methods are available.
mpfrVersion() (x <- c(Const("pi", 64), mpfr(-2:2, 64))) mpfrIs0(x) # one of them is x[mpfrIs0(x)] # but it may not have been obvious.. str(x) x <- rep(-2:2, 5) stopifnot(is.whole(mpfr(2, 500) ^ (1:200)), all.equal(diff(x), diff(as.numeric(x))))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.