Open robertodr opened 5 years ago
I will test this and once we have more data we can think about what we do with it.
After a bit of reading (in particular https://docs.python.org/3/library/json.html#implementation-limitations), we can expect the serialized data to contain the same range and precision as the Python data types. But whether we lose the range and precision depends on who is reading the JSON.
If Python, my guess is that there is no significant loss. But with other JSON implementations, I guess it depends.
I also tested this locally Python -> JSON -> Python. But I haven't tested reading into another language with another implementation.
@stigrj can you run some tests in cpp-parselglossy? We need to check this also for the Fortran and C examples. If those JSON libraries do not present this problem, then I think we can document our preference for the JSON libraries for compiled languages and warning people about this possible pitfall with libraries we have not personally tested.
On a different note, I've never set a floating point parameter in an input file that employed the full range and precision... Any other input parser would hit the same problem, I think.
I also think that this is not a JSON-specific problem but basically a problem of reading a number from file. We should check how C and Fortran read floats, testing both range and precision.
Let's move this issue to the respective tutorial repositories?
On Thu, Apr 11, 2019 at 11:22 AM Radovan Bast notifications@github.com wrote:
I also think that this is not a JSON-specific problem but basically a problem of reading a number from file. We should check how C and Fortran read floats, testing both range and precision.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dev-cafe/parselglossy/issues/72#issuecomment-482160046, or mute the thread https://github.com/notifications/unsubscribe-auth/ADiXEY2hicMLJxAqfQJinPWpVS9crjUyks5vf1M4gaJpZM4ciGWY .
-- Roberto Di Remigio
Where will we document our findings? On the lib side or the tutorial side?
A mention on both sides seems the safest bet.
I was not aware of this, but apparently reading from/writing to JSON can mess up precision of floating point numbers. I don't really know how to test and prevent this...