opencpu / opencpu

OpenCPU system for embedded scientific computation and reproducible research
https://www.opencpu.org
Other
726 stars 121 forks source link

OpenCPU cannot display value between 1e-05 to ~1e-04 with JSON format #315

Open slfan2013 opened 6 years ago

slfan2013 commented 6 years ago

Strange that OpenCPU cannot display the values between 1e-05 to ~1e-04 correctly. All these values will be returned as exact 0.

Here is the R code,

test_bug = function(){
  # genrate values from 1e-05 to 1e-04
  data = data.frame(value = c(seq(0.00001,0.0001,by=0.0000001)))
  return(data)
  }

There is no error in the format of print or csv. However, the format of json is incorrect. The url of http://localhost:5656/ocpu/tmp/x0567909793/R/.val/print would return

        value
1   0.0000100
2   0.0000101
3   0.0000102
4   0.0000103
5   0.0000104
...

However, the url of http://localhost:5656/ocpu/tmp/x0567909793/R/.val/json returns

[
  {
    "value": 1e-005
  },
  {
    "value": 0
  },
  {
    "value": 0
  },
  {
    "value": 0
  },...]

This is critical to me because I often extract the result using session.getObject(function(obj){}), where the obj is in the json format.

jeroen commented 6 years ago

Try adding ?digits=10 to the json Url.

slfan2013 commented 6 years ago

Thanks a lot. It works for the URL. However, is there a way of displaying 10 digits for obj in the session.getObject(function(obj){})? My obj output is still 0s.