-
Notifications
You must be signed in to change notification settings - Fork 42
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
Options for better-looking outputs of to_chars
#35
Comments
Thank you so much for your kind words!
Yes. The intention is to match what the Ryu library spits out (which is always in the scientific form with I know this is probably not what people usually want. It might be more useful if
I want to also say that writing your own Nevertheless, it is very much welcome if anybody comes up with a generic mechanism for specifying the formatting details, and I would be even happier if anyone opens a PR for that, but right now I have no plan for doing so by myself. |
@alugowski It it helps, the C++ fmt library uses the Dragonbox algorithm under the hood, and you can control its output exactly the way you want. |
Ah right. I forgot to mention that. Thanks @ecorm. |
Thank you for the detailed explanation! My question came from the sentence in the README that says the "output is of the shortest length". So I was expecting to see "1" instead of "1E0". I actually came to find this project by looking for alternatives to Since I need both writing and reading, I found Dragonbox as a usable analog of I don't know what your ambitions are, but I think if you're interested then both Clang and GCC could use your work. Regarding your "everyone wants something else" point, that true. The https://en.cppreference.com/w/cpp/utility/to_chars Now don't get me started on |
In fact, if you look carefully at what it says:
So the shortness is in terms of the number of (significand) digits, not in terms of the number of characters. I mean, it's confusing I admit, but the exact number of characters is not the most interesting detail from the point of view of developing a conversion algorithm.
If
As far as I know, Dragonbox has been considered for libc++ implementation of Adoption into the standard library is something I ultimately want for, and this was an attempt for preparing that. But I was way too ambitious and could not really afford the required amount of time and effort, so that project is "dead" at this point. I'm very slowly making some progress (e.g. developing this) though.
This is also something in my TODO list. May take long to be realized.
IIRC
Simply put, the reason why I'm sort of hesitant in writing some more useful version of I would say this again: it's not super daunting to implement your own Well I don't know. I may write a shitty one if I get some time and post it here. |
Hmm. I guess I somewhat sounded like a jerk 😅 Sorry about that. I think your suggestion about providing an alternative interface doing By the way, it won't be a drop-in replacement for |
1.0 is rendered as '1E0' instead of just '1'. Drop such suffixes, as Dragonbox does not offer an option to do so. See jk-jeon/dragonbox#35
to_chars
Great package! Thank you!
I've noticed that
to_chars
sometimes emits an extraE0
suffix when it's not needed. For example, the number1.0
is emitted as1E0
.Is this intentional?
The text was updated successfully, but these errors were encountered: