@@ -237,11 +237,24 @@ class DoubleToStringConverter {
237237 // kBase10MaximalLength significant digits).
238238 // "-1.7976931348623157e+308", "-1.7976931348623157E308"
239239 // In addition, the buffer must be able to hold the trailing '\0' character.
240+ //
241+ // Since the algorithm finds the shortest number of significant digits, it
242+ // can produce an output that isn't the shortest possible if the
243+ // decimal_in_shortest_high is high enough. For example, the number
244+ // 1e23 could be written as 99999999999999991611392 with 23
245+ // digits, however, it only needs one significant digit 1, and thus the
246+ // result is 100000000000000000000000, which has 24 digits.
240247 bool ToShortest (double value, StringBuilder* result_builder) const {
241248 return ToShortestIeeeNumber (value, result_builder, SHORTEST);
242249 }
243250
244251 // Same as ToShortest, but for single-precision floats.
252+ //
253+ // Since the algorithm finds the shortest number of significant digits, it
254+ // can, in very rare cases, produce an output that isn't the shortest possible.
255+ // For example, the number 1e11f could be written as 99999997952 with 11
256+ // digits, however, it only needs one significant digit 1, and thus the
257+ // result is 100000000000, which has 12 digits.
245258 bool ToShortestSingle (float value, StringBuilder* result_builder) const {
246259 return ToShortestIeeeNumber (value, result_builder, SHORTEST_SINGLE);
247260 }
0 commit comments