Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Integration in fmt (basically c++20 std::format) #1

Closed
SanderBouwhuis opened this issue Mar 30, 2020 · 4 comments
Closed

Integration in fmt (basically c++20 std::format) #1

SanderBouwhuis opened this issue Mar 30, 2020 · 4 comments

Comments

@SanderBouwhuis
Copy link

Is there any chance you could submit your double-to-ascii magic to the fmt library?
In this topic fmtlib/fmt#1426 you mention your implementation is a lot (maybe 3x) faster than the current implementation.

  1. I don't dare submit it because I'm afraid I might screw up things.
  2. Is it even 'legal' to make use of your double-to-ascii code in the fmt library?
@erthink
Copy link
Owner

erthink commented Mar 31, 2020

@SanderBouwhuis, there are four main scenarios for using the double-to-string conversion:

  1. given precision with rounding, e.g. 0.123456e+789.
  2. given length with rounding (i.e. to choice useful format while number of chars is fixed).
  3. to produce a shortest string representation which roundtrip-convertible to an original double value, e.g. for serialization to JSON.
  4. to produce a long decimal representations with the given error value.

Historically and for now, my implementation supports third case only. For support other cases a significant changes/improvements are required. I do this as I have free time, but this job is not done...

In addition, it is not obvious that such improvements are really needed in {fmt} and will pass the review since significantly increase the volume and complexity of the code. For instance, support for 80-bit and 128-bit IEEE-754 formats requires 128-bit integer arithmetic and so on.

@vitaut, FYI.

@SanderBouwhuis
Copy link
Author

Aha, ok. That makes things clear.
I'm glad I didn't try this myself then.

All things said though, you did some very impressive optimizations. I assume you are using the Ryu implementation as a basis? Or is this Grisu-3?

@erthink
Copy link
Owner

erthink commented Mar 31, 2020

I assume you are using the Ryu implementation as a basis? Or is this Grisu-3?

Take look to #1, #2.

@SanderBouwhuis
Copy link
Author

Thanks, I hadn't seen that part.
Good luck with trying to make the conversion complete!

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants