4

I'm looking for a package or any other solution that will help me in handling fixed point decimal numbers, their arithmetic and rounding in R. The main purpose is to make monetary calculations without floating point errors and being able to control precision and rounding.

I've done a research for eg. I've read about Brobdingnag, Rmpfr, gmp. Also I've taken a look at some threads that were discussing the topic like for eg. this one and these that were mentioned over there (and many others). It's a pity, but none offers a solution that fullfils my requirements which are as follows. As the found questions are old I allow myself to refresh the issue.

The requirements for a package/solution are:

  1. It let us get exact decimal representation.
  2. It supports fixed point arithmetic.
  3. We are able to control precision and rounding.
  4. It let print a number to decimal.

I would point Python's Decimal or Java's Big Decimal packages as examples which meet all the criteria and am looking for an equivalent in R.

I hope that some of you may have an idea what can help or how to prepare our own solution. Supposedly this topic can help somebody else, too.

Looking forward for your response and thanks in advance.

Tomasz

Tomasz
  • 41
  • 2
  • https://cran.r-project.org/web/packages/Rmpfr/vignettes/Rmpfr-pkg.pdf https://stackoverflow.com/questions/2053397/long-bigint-decimal-equivalent-datatype-in-r – Ray Tayek Aug 01 '18 at 17:26
  • @RayTayek, thanks for the input. However, Brobdingnag prints values in the expotential form which I cannot accept as I need to print values out in a user friendly way. Rmpfr offers only arbitrary precison which is not satisfying either. Gmp seems not to handle big integers dividing. Unless I've missed something. Then feel free to correct me. – Tomasz Aug 02 '18 at 08:27
  • @Tomasz did you find something? – Mematematica Jun 22 '20 at 03:47
  • @Mematematica, eventually we migrate to Node.js and its BigNumber library. – Tomasz Oct 08 '20 at 10:53

0 Answers0