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

Add github.com/cespare/ryu to list of implementations #86

Merged
merged 1 commit into from
Jan 14, 2019

Conversation

cespare
Copy link
Contributor

@cespare cespare commented Jan 13, 2019

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.)

Format the ever-growing list as a table.
README.md Show resolved Hide resolved
@ulfjack ulfjack mentioned this pull request Jan 14, 2019
@ulfjack
Copy link
Owner

ulfjack commented Jan 14, 2019

Hi Caleb, thank you for the contribution!

I'll take a look at #85 after merging this.

I thought about special-casing integers, but haven't had time to implement that yet. Let me file a feature request for that.

@ulfjack ulfjack merged commit 3673de0 into ulfjack:master Jan 14, 2019
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

Successfully merging this pull request may close these issues.

None yet

3 participants