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

Display of Float128 values #66

Open
nhabedi opened this issue Aug 13, 2023 · 2 comments
Open

Display of Float128 values #66

nhabedi opened this issue Aug 13, 2023 · 2 comments

Comments

@nhabedi
Copy link

nhabedi commented Aug 13, 2023

The following two inputs result in the same number, i.e. x === y:

x = parse(Float128,"1e-33")
y = parse(Float128,"1.00000000000000000000000000000000005e-33")

But they are displayed as 1.00000000000000000000000000000000005e-33. Shouldn't the policy be to choose the simpler form 1e-33 for display if both are correct?

@RalphAS
Copy link
Collaborator

RalphAS commented Aug 14, 2023

Yes, simpler forms would be preferable. However this is quite difficult in general (I'll refer you to the literature on the Dragon and Grisu algorithms for Float32 and Float64). We currently rely on the formatting provided by libquadmath; its maintainers may be able to say whether improvements are feasible.

@nhabedi
Copy link
Author

nhabedi commented Aug 14, 2023

Yes, I know this is tricky. I noticed this problem because I was testing my own implementation of the Burger/Dybvig algorithm which gives the correct answer in this particular case. It's not a big deal and it's fine with me if you close this issue. If I find enough time I might be tempted to port the algorithm to Julia, but I'm not very good at writing optimized Julia code yet and whatever I come up with will most likely be too slow for production code.

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