I see there are existing extended precision packages: Ryacas and Rmpfr, you might want to take a look at them and their representation of numbers with higher precision than a double.
best Vladimir Dergachev On Fri, 19 Jul 2024, Khue Tran wrote:
Hi, I am trying to create an Rcpp package that involves arbitrary precise calculations. The function to calculate e^x below with 100 digits precision works well with integers, but for decimals, since the input is a double, the result differs a lot from the arbitrary precise result I got on Wolfram. I understand the results are different since 0.1 cannot be represented precisely in binary with limited bits. It is possible to enter 1 then 10 and get the multiprecision division of these two integers to attain a more precise 0.1 in C++, but this method won't work on a large scale. Thus, I am looking for a general solution to get more precise inputs?
______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel