Thanks Martin, looks like the update fixed the issue.
The round2 function is just to format the output.
now I can get the correct result:
library(Rmpfr)
sprintf("%#.2f", round(mpfr(1.152, 200),2))
round2(1.152, 2)
#[1] "1.15"
Artur
2014-11-27 7:10 GMT-02:00 Martin Maechler :
>> Artur Augus
> Artur Augusto
> on Wed, 19 Nov 2014 15:26:12 -0200 writes:
> I'm trying to use the Rmpfr library with the round() function to apply
> the round half to even rule and achieve correct results, without
> errors due the finite precision of float point values.
> Example
I'm trying to use the Rmpfr library with the round() function to apply
the round half to even rule and achieve correct results, without
errors due the finite precision of float point values.
Example of problem:
round(1.225,2)
#[1] 1.23
So far, this is what I've achieved:
library(Rmpfr)
x <- c(1
3 matches
Mail list logo