Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does yyjson have parameters to set decimal places? #158

Open
wang21825227 opened this issue Feb 26, 2024 · 4 comments
Open

Does yyjson have parameters to set decimal places? #158

wang21825227 opened this issue Feb 26, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@wang21825227
Copy link

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.

@ibireme
Copy link
Owner

ibireme commented Feb 26, 2024

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

@wang21825227
Copy link
Author

Will you consider supporting setting this writing parameter later?

@ibireme
Copy link
Owner

ibireme commented Mar 1, 2024

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.

@ibireme ibireme added the enhancement New feature or request label Mar 1, 2024
@jagoly
Copy link

jagoly commented Mar 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants