ibireme/yyjson

Does yyjson have parameters to set decimal places?

wang21825227 opened this issue · 5 comments

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

No, yyjson writes floating point numbers using the Schubfach algorithm, which converts floating point numbers to the shortest possible decimal representation.

Will you consider supporting setting this writing parameter later?

I'll consider supporting it in the future, but it's not a high priority at the moment.

Implementing this feature would require rewriting the internal float-point writing algorithm, which could be complex and may affect performance.

A potentially simpler feature that I would like is the ability to write out numbers as if they were 32 bit floats. In my project (a game), all of my real numbers are 32 bit. I've got an editor that can edit things and write out json, but converting values from floats to doubles results in nice short values like 0.8 instead being written out as 0.800000011920929.