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

D Ryu implementation reference #194

Merged
merged 1 commit into from
Jan 27, 2021
Merged

D Ryu implementation reference #194

merged 1 commit into from
Jan 27, 2021

Conversation

9il
Copy link
Contributor

@9il 9il commented Dec 13, 2020

Hi Ulf,

Thank you for the great algorithm!

Mir/Dlang ryu port

We have only generic implementation for now.

Additional optimizations were applied:

  1. Mir fixed-length integers UInt!128 and UInt!256 are used instead of C's uint128 and manual ulong[4] (for uint256). They were implemented with LLVM intrinsics and generates ideal (or almost ideal) code for multiplications.
  2. /= and %= 10 operations are fused where possible and implemented using multiplication. C's uint128 doesn't support this kind of optimization for now and performs the actual call of divide function.
  3. UInt!64 is used for UInt!128 for doubleandfloat`, all this reduces instructions size a lot.
  4. Reimplemented pow5Factor using modular inverse. #188 + minor additional optimization
  5. A modification similar to More efficient removing of trailing zeros #156
  6. decimal length isn't used at all. Instead, we print the number to the buffer and return its position in the buffer. In a practical case, this would work faster. Mir/D's printing routines get this buffer size and copy it to the actual string appender (or Mir's stack-allocated SmallString).

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.

2 participants