-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
As we have implemented Dragon4 in dotnet/coreclr#12894 , we have a good start to improve the performance of double.ToString().
Although Dragon4 makes current double.ToString() much faster than previous implementation, we could do better. The algorithm Grisu3 introduced in this paper eliminated the big integer arithmetic so that it's much faster than Dragon4. However, not all numbers are applicable for using Grisu3. For those exclusive numbers, we can fall back to Dragon4. Quote from the paper:
As a consequence
Grisu3 is incomplete and will fail for some percentage of its input.
Given 11 extra bits roughly 99.5% are processed correctly and
are thus guaranteed to be optimal (with respect to shortness and
rounding). The remaining 0.5% are rejected and need to be printed
by another printing algorithm (like Dragon4).
Note Google's V8 engine has already adopted this algorithm. @tannergooding @tarekgh @jkotas I'm wondering is it a good timing for diving into this algorithm - I need sometime to do POC for it or in case of any concern from you guys.