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

How to avoid outputting small floats in scientific notation #893

Closed
bryanp opened this issue Aug 10, 2023 · 6 comments
Closed

How to avoid outputting small floats in scientific notation #893

bryanp opened this issue Aug 10, 2023 · 6 comments

Comments

@bryanp
Copy link

bryanp commented Aug 10, 2023

Small floats are dumped in scientific notation:

irb(main):002:0> Oj.dump(0.0000000001)
=> "1e-10"

I don't see an option to prevent this. Curious if there's a way to accomplish this.

@ohler55
Copy link
Owner

ohler55 commented Aug 10, 2023

Right now there is not a way to control the output format other than the precision.

@bryanp
Copy link
Author

bryanp commented Aug 11, 2023

Is this a change you'd be open to seeing? I'm thinking of a new float_format option that is a format string.

@ohler55
Copy link
Owner

ohler55 commented Aug 11, 2023

Possibly. I'll be messing with the options this weekend. I could add that in.

@ohler55
Copy link
Owner

ohler55 commented Aug 13, 2023

Please try the "more-options" branch.

@bryanp
Copy link
Author

bryanp commented Aug 14, 2023

This looks like exactly what I'm after!

@ohler55
Copy link
Owner

ohler55 commented Aug 16, 2023

Release v3.16.0 with the fix.

@ohler55 ohler55 closed this as completed Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants