1

I can not figure out how to control the output from jsonlite::toJSON() so that high precision numbers are represented as is.

For example:

l <- list(x = 1.001000000000987466525, y = 0.0000022624065747878902023)
jsonlite::toJSON(l, pretty = TRUE, digits = NA, auto_unbox = TRUE)

{
  "x": 1.00100000000099,
  "y": 2.26240657478789e-06
} 

I would like the output of toJSON to preserve the exact value in l as follows:

{
  "x": 1.001000000000987466525,
  "y": 0.0000022624065747878902023
} 

Can this be done?

Kevin Burnham
  • 553
  • 2
  • 13
  • 1
    It's impossible, in `l` they already striped to 15 significant digits. You can only store them as a string and use long arithmetic. – m0nhawk Jan 31 '18 at 21:42

0 Answers0