Add github.com/cespare/ryu to list of implementations #86
+9
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also format the ever-growing list as a table.
Thanks for this algorithm and the implementation! Next I'm planning on changing the Go stdlib itself to use Ryu as its float formatting algorithm.
Two things I noticed while working on this:
It seemed like one of the optimizations for handling two digits at a time might have been intended to be a loop rather than a single if statement. I brought this up over at Missing loop in two-digit optimization? #85.
While comparing performance against the Go stdlib, I copied an optimization that's used there. If a float f represents an integer value and it is within the range where every integer is representable, then we can skip most of the expensive work and construct the decimal representation directly. (See here and here.) If you're handling random floats then this doesn't happen very often but in real life scenarios I imagine that numbers like 1.0 and 10.0 are overrepresented.
(This is probably a well-known optimization but I wanted to mention it since that was the main optimization I needed to add to my Ryu implementation in order to reach parity with the Go stdlib on all my test inputs.)