jeroen / jsonlite

A Robust, High Performance JSON Parser and Generator for R
http://arxiv.org/abs/1403.2805
Other
376 stars 40 forks source link

Number of decimals does not hold with toJSON #243

Open themellion opened 6 years ago

themellion commented 6 years ago

I am using the following:

jsonlite::toJSON(0.9618000000000000992983, force = TRUE, na = "string", digits = 22, pretty = TRUE, auto_unbox = TRUE, use_signif = TRUE)

and I am getting: 0.9618

Is there a way to keep all the decimals, i.e. 0.9618000000000000992983.

Thanks

byapparov commented 5 years ago

This is not exactly the problem of the jsonlite packge:

toJSON(0.9618001001001001192983,  digits =  22)
# [0.9618001001001] 

0.9618001001001001 == 0.9618001001001001192983
#274 [1] TRUE

See this question for explanation

byapparov commented 5 years ago

Duplicates #231