summaryrefslogtreecommitdiffstats
path: root/mfbt/double-conversion/ToPrecision-exponential.patch
blob: d36a0d7439345686d00b11b33686c80755d501ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.cc b/mfbt/double-conversion/double-conversion/double-to-string.cc
--- a/mfbt/double-conversion/double-conversion/double-to-string.cc
+++ b/mfbt/double-conversion/double-conversion/double-to-string.cc
@@ -290,17 +290,19 @@ bool DoubleToStringConverter::ToExponent
                                   exponent,
                                   result_builder);
   return true;
 }
 
 
 bool DoubleToStringConverter::ToPrecision(double value,
                                           int precision,
+                                          bool* used_exponential_notation,
                                           StringBuilder* result_builder) const {
+  *used_exponential_notation = false;
   if (Double(value).IsSpecial()) {
     return HandleSpecialValues(value, result_builder);
   }
 
   if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) {
     return false;
   }
 
@@ -332,16 +334,17 @@ bool DoubleToStringConverter::ToPrecisio
        max_trailing_padding_zeroes_in_precision_mode_)) {
     // Fill buffer to contain 'precision' digits.
     // Usually the buffer is already at the correct length, but 'DoubleToAscii'
     // is allowed to return less characters.
     for (int i = decimal_rep_length; i < precision; ++i) {
       decimal_rep[i] = '0';
     }
 
+    *used_exponential_notation = true;
     CreateExponentialRepresentation(decimal_rep,
                                     precision,
                                     exponent,
                                     result_builder);
   } else {
     CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point,
                                 (std::max)(0, precision - decimal_point),
                                 result_builder);
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.h b/mfbt/double-conversion/double-conversion/double-to-string.h
--- a/mfbt/double-conversion/double-conversion/double-to-string.h
+++ b/mfbt/double-conversion/double-conversion/double-to-string.h
@@ -273,16 +273,17 @@ class DoubleToStringConverter {
   //     been provided to the constructor,
   //   - precision < kMinPericisionDigits
   //   - precision > kMaxPrecisionDigits
   // The last condition implies that the result will never contain more than
   // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
   // exponent character, the exponent's sign, and at most 3 exponent digits).
   MFBT_API bool ToPrecision(double value,
                    int precision,
+                   bool* used_exponential_notation,
                    StringBuilder* result_builder) const;
 
   enum DtoaMode {
     // Produce the shortest correct representation.
     // For example the output of 0.299999999999999988897 is (the less accurate
     // but correct) 0.3.
     SHORTEST,
     // Same as SHORTEST, but for single-precision floats.