Learn R Programming

Rmpfr (version 0.2-3)

mpfr-class: Class "mpfr" of Multiple Precision Floating Point Numbers

Description

"mpfr" is the class of Multiple Precision Floatingpoint numbers with Reliable arithmetic.

For the high-level user, "mpfr" objects should behave as standard R's numeric vectors, just with prespecified (typically high) precision.

Arguments

Objects from the Class

Objects are typically created by mpfr(, precBits).

See Also

The "mpfrMatrix" class, which extends the "mpfr" one.

Examples

Run this code
## 30 digit precision
str(x <- mpfr(c(2:3, pi), prec = 30 * log2(10)))
x^2
x[1] / x[2] # 0.66666... ~ 30 digits

## factorial() and lfactorial() would work automagically via gamma();
## factorial() has method that rounds
f200 <- factorial(mpfr(200, prec = 1500)) # need high prec.!
f200
as.numeric(log2(f200))# 1245.38 -- need precBits >~ 1246 for full precision

## More extreme
f.1e4 <- factorial(mpfr(10000, prec=1+lfactorial(10000)/ log(2)))
getPrec(f.1e4) # 118459
str(f.1e4)

Run the code above in your browser using DataLab