Bug 608915 - part 1 - extend ToPrecision to tell use whether exponential notation was used; r=Waldo

This commit is contained in:
Nathan Froyd 2013-11-07 12:46:05 -05:00
parent b9cb6aeb20
commit 19ffd38bd1
4 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,35 @@
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 {

View File

@ -283,7 +283,9 @@ bool DoubleToStringConverter::ToExponential(
bool DoubleToStringConverter::ToPrecision(double value, bool DoubleToStringConverter::ToPrecision(double value,
int precision, int precision,
bool* used_exponential_notation,
StringBuilder* result_builder) const { StringBuilder* result_builder) const {
*used_exponential_notation = false;
if (Double(value).IsSpecial()) { if (Double(value).IsSpecial()) {
return HandleSpecialValues(value, result_builder); return HandleSpecialValues(value, result_builder);
} }
@ -325,6 +327,7 @@ bool DoubleToStringConverter::ToPrecision(double value,
decimal_rep[i] = '0'; decimal_rep[i] = '0';
} }
*used_exponential_notation = true;
CreateExponentialRepresentation(decimal_rep, CreateExponentialRepresentation(decimal_rep,
precision, precision,
exponent, exponent,

View File

@ -270,6 +270,7 @@ class DoubleToStringConverter {
// exponent character, the exponent's sign, and at most 3 exponent digits). // exponent character, the exponent's sign, and at most 3 exponent digits).
MFBT_API bool ToPrecision(double value, MFBT_API bool ToPrecision(double value,
int precision, int precision,
bool* used_exponential_notation,
StringBuilder* result_builder) const; StringBuilder* result_builder) const;
enum DtoaMode { enum DtoaMode {

View File

@ -20,3 +20,4 @@ patch -p3 < add-mfbt-api-markers.patch
patch -p3 < use-StandardInteger.patch patch -p3 < use-StandardInteger.patch
patch -p3 < use-mozilla-assertions.patch patch -p3 < use-mozilla-assertions.patch
patch -p3 < use-static_assert.patch patch -p3 < use-static_assert.patch
patch -p3 < ToPrecision-exponential.patch