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.
/= 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.
UInt!64 is used for UInt!128 fordoubleandfloat`, all this reduces instructions size a lot.
188 + minor additional optimization
A modification similar to #156
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).
Hi Ulf,
Thank you for the great algorithm!
Mir/Dlang ryu port
We have only generic implementation for now.
Additional optimizations were applied:
UInt!128
andUInt!256
are used instead of C'suint128
and manualulong[4]
(foruint256
). They were implemented with LLVM intrinsics and generates ideal (or almost ideal) code for multiplications.uint128
doesn't support this kind of optimization for now and performs the actual call of divide function.UInt!64
is used forUInt!128 for
doubleand
float`, all this reduces instructions size a lot.188 + minor additional optimization
SmallString
).