Grisu is a fast, new (2010) algorithm for converting a floating-point number to a decimal string. It was introduced in a paper by Florian Loitsch (http://dl.acm.org/citation.cfm?doid=1809028.1806623) and the author claims it to be as much as 4 times faster than previous techniques. The code here is a port of the C++ code in the "double-conversion" project on Google Code (http://code.google.com/p/double-conversion/) to C#.
BSD 3-Clause "New" or "Revised" License
45
stars
9
forks
source link
Fix edge cases where decimal representation is chosen instead of a shorter exponential representation. #3
The logic for calculating the lengths of the two representations was incorrect.
For example:
-0.0005401035826582183
(previously written instead of)-5.401035826582183e-4
(shorter)