Podger2016 / rapidjson

Automatically exported from code.google.com/p/rapidjson
0 stars 0 forks source link

WriteDouble loses precision after 6 significant digits #68

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
WriteDouble loses precision after 6 significant digits. It'd be useful to have 
more than 6. E.g. something like 1338594359000 comes out as 1.33859e+12, losing 
some information.

I notice this is because rapidjson uses %g in a format string. Would %f be 
acceptable? There's also a todo comment stating "Optimization with custom 
double-to-string converter." Perhaps that would address this problem instead. 
And finally, I believe format strings allow the user to specify the precision. 
Could this be an option exposed to the rapidjson user?

Thanks for the consideration.

Original issue reported on code.google.com by ron....@gmail.com on 23 Apr 2013 at 3:22

GoogleCodeExporter commented 8 years ago
You can find an implementation of this functionality in a pull-request in my 
personal fork at GitHub, see https://github.com/pah/rapidjson/pull/3

In addition to explicitly specifying a precision with each writer.Double() 
call, you can tell the Writer classes to use a user-defined precision via
  writer.SetDoublePrecision(...);

This proposal does not address the todo to provide an optimization with a 
custom double-to-string converter.  Neither does it provide a way to switch 
from a %g to a %f format string behaviour.

Pull-request: https://github.com/pah/rapidjson/pull/3
Latest patch: https://github.com/pah/rapidjson/pull/3.patch

Original comment by philipp....@gmail.com on 2 Apr 2014 at 4:09

GoogleCodeExporter commented 8 years ago

Original comment by milo...@gmail.com on 26 Jun 2014 at 2:44