mfbt/double-conversion/ToPrecision-exponential.patch
author André Bargull <andre.bargull@gmail.com>
Tue, 18 Oct 2016 11:46:21 -0700
changeset 318543 04d607a4816550a043fabb1934adfb5f7cfd754a
parent 154422 0d307cd90c342d59f0289a46f0063bb26f5e724d
child 331778 89b895c219f2b97fc0ded8877b30c337e697bdaa
permissions -rw-r--r--
Bug 1310733 - Part 0: Rename tzdata svn directory to "source" instead of using version name. r=Waldo

1e7bf0c636b8cca54dd83456a0f8fa219343e2a1 Bug 608195 - part 2 - extend ToPrecision to tell use whether exponential notation was used
diff --git a/mfbt/double-conversion/double-conversion.cc b/mfbt/double-conversion/double-conversion.cc
index febba6c..394b6a0 100644
--- a/mfbt/double-conversion/double-conversion.cc
+++ b/mfbt/double-conversion/double-conversion.cc
@@ -283,7 +283,9 @@ bool DoubleToStringConverter::ToExponential(
 
 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);
   }
@@ -325,6 +327,7 @@ bool DoubleToStringConverter::ToPrecision(double value,
       decimal_rep[i] = '0';
     }
 
+    *used_exponential_notation = true;
     CreateExponentialRepresentation(decimal_rep,
                                     precision,
                                     exponent,
diff --git a/mfbt/double-conversion/double-conversion.h b/mfbt/double-conversion/double-conversion.h
index 0900ba0..957575c 100644
--- a/mfbt/double-conversion/double-conversion.h
+++ b/mfbt/double-conversion/double-conversion.h
@@ -270,6 +270,7 @@ class DoubleToStringConverter {
   // 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 {