Rmpfr (version 0.5-3)

roundMpfr: Rounding to Binary bits, "mpfr-internally"

Description

Rounding to binary bits, not decimal digits. Closer to the number representation, this also allows to increase or decrease a number's precBits. In other words, it acts as setPrec(), see getPrec().

Usage

roundMpfr(x, precBits)

Arguments

x
an mpfr number (vector)
precBits
integer specifying the desired precision in bits.

Value

  • an mpfr number as x but with the new 'precBits' precision

See Also

The mpfr class group method Math2 implements a method for round(x, digits) which rounds to decimal digits.

Examples

Run this code
(p1 <- Const("pi", 100)) # 100 bit prec
 roundMpfr(p1, 120) # 20 bits more, but "random noise"
 Const("pi", 120)   # same "precision", but really precise
stopifnot(120 == getPrec(roundMpfr(p1, 120)),
            75 == getPrec(roundMpfr(p1,  75)))

Run the code above in your browser using DataLab