Skip to content

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

2 participants