summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/double-conversion/double-conversion/strtod.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/double-conversion/double-conversion/strtod.cc')
-rw-r--r--src/3rdparty/double-conversion/double-conversion/strtod.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/3rdparty/double-conversion/double-conversion/strtod.cc b/src/3rdparty/double-conversion/double-conversion/strtod.cc
index 24fd85990e..5fb1b2f104 100644
--- a/src/3rdparty/double-conversion/double-conversion/strtod.cc
+++ b/src/3rdparty/double-conversion/double-conversion/strtod.cc
@@ -101,17 +101,6 @@ static Vector<const char> TrimLeadingZeros(Vector<const char> buffer) {
return Vector<const char>(buffer.start(), 0);
}
-
-static Vector<const char> TrimTrailingZeros(Vector<const char> buffer) {
- for (int i = buffer.length() - 1; i >= 0; --i) {
- if (buffer[i] != '0') {
- return buffer.SubVector(0, i + 1);
- }
- }
- return Vector<const char>(buffer.start(), 0);
-}
-
-
static void CutToMaxSignificantDigits(Vector<const char> buffer,
int exponent,
char* significant_buffer,
@@ -536,6 +525,12 @@ float Strtof(Vector<const char> buffer, int exponent) {
TrimAndCut(buffer, exponent, copy_buffer, kMaxSignificantDecimalDigits,
&trimmed, &updated_exponent);
exponent = updated_exponent;
+ return StrtofTrimmed(trimmed, exponent);
+}
+
+float StrtofTrimmed(Vector<const char> trimmed, int exponent) {
+ DOUBLE_CONVERSION_ASSERT(trimmed.length() <= kMaxSignificantDecimalDigits);
+ DOUBLE_CONVERSION_ASSERT(AssertTrimmedDigits(trimmed));
double double_guess;
bool is_correct = ComputeGuess(trimmed, exponent, &double_guess);
@@ -555,7 +550,7 @@ float Strtof(Vector<const char> buffer, int exponent) {
// low-precision (3 digits):
// when read from input: 123
// when rounded from high precision: 124.
- // To do this we simply look at the neigbors of the correct result and see
+ // To do this we simply look at the neighbors of the correct result and see
// if they would round to the same float. If the guess is not correct we have
// to look at four values (since two different doubles could be the correct
// double).