summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/double-conversion/double-conversion
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/double-conversion/double-conversion')
-rw-r--r--src/3rdparty/double-conversion/double-conversion/bignum.cc12
-rw-r--r--src/3rdparty/double-conversion/double-conversion/double-to-string.cc13
-rw-r--r--src/3rdparty/double-conversion/double-conversion/double-to-string.h27
-rw-r--r--src/3rdparty/double-conversion/double-conversion/string-to-double.cc4
-rw-r--r--src/3rdparty/double-conversion/double-conversion/utils.h13
5 files changed, 54 insertions, 15 deletions
diff --git a/src/3rdparty/double-conversion/double-conversion/bignum.cc b/src/3rdparty/double-conversion/double-conversion/bignum.cc
index d6745d755a..5c74d70d3d 100644
--- a/src/3rdparty/double-conversion/double-conversion/bignum.cc
+++ b/src/3rdparty/double-conversion/double-conversion/bignum.cc
@@ -147,7 +147,7 @@ void Bignum::AssignHexString(Vector<const char> value) {
}
if (tmp > 0) {
DOUBLE_CONVERSION_ASSERT(tmp <= kBigitMask);
- RawBigit(used_bigits_++) = (tmp & kBigitMask);
+ RawBigit(used_bigits_++) = static_cast<Bignum::Chunk>(tmp & kBigitMask);
}
Clamp();
}
@@ -204,7 +204,7 @@ void Bignum::AddBignum(const Bignum& other) {
carry = sum >> kBigitSize;
++bigit_pos;
}
- used_bigits_ = (std::max)(bigit_pos, static_cast<int>(used_bigits_));
+ used_bigits_ = static_cast<int16_t>(std::max(bigit_pos, static_cast<int>(used_bigits_)));
DOUBLE_CONVERSION_ASSERT(IsClamped());
}
@@ -240,7 +240,7 @@ void Bignum::ShiftLeft(const int shift_amount) {
if (used_bigits_ == 0) {
return;
}
- exponent_ += (shift_amount / kBigitSize);
+ exponent_ += static_cast<int16_t>(shift_amount / kBigitSize);
const int local_shift = shift_amount % kBigitSize;
EnsureCapacity(used_bigits_ + 1);
BigitsShiftLeft(local_shift);
@@ -418,7 +418,7 @@ void Bignum::Square() {
DOUBLE_CONVERSION_ASSERT(accumulator == 0);
// Don't forget to update the used_digits and the exponent.
- used_bigits_ = product_length;
+ used_bigits_ = static_cast<int16_t>(product_length);
exponent_ *= 2;
Clamp();
}
@@ -739,8 +739,8 @@ void Bignum::Align(const Bignum& other) {
for (int i = 0; i < zero_bigits; ++i) {
RawBigit(i) = 0;
}
- used_bigits_ += zero_bigits;
- exponent_ -= zero_bigits;
+ used_bigits_ += static_cast<int16_t>(zero_bigits);
+ exponent_ -= static_cast<int16_t>(zero_bigits);
DOUBLE_CONVERSION_ASSERT(used_bigits_ >= 0);
DOUBLE_CONVERSION_ASSERT(exponent_ >= 0);
diff --git a/src/3rdparty/double-conversion/double-conversion/double-to-string.cc b/src/3rdparty/double-conversion/double-conversion/double-to-string.cc
index 9255bce171..215eaa96d4 100644
--- a/src/3rdparty/double-conversion/double-conversion/double-to-string.cc
+++ b/src/3rdparty/double-conversion/double-conversion/double-to-string.cc
@@ -56,7 +56,7 @@ bool DoubleToStringConverter::HandleSpecialValues(
StringBuilder* result_builder) const {
Double double_inspect(value);
if (double_inspect.IsInfinite()) {
- if (infinity_symbol_ == NULL) return false;
+ if (infinity_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
if (value < 0) {
result_builder->AddCharacter('-');
}
@@ -64,7 +64,7 @@ bool DoubleToStringConverter::HandleSpecialValues(
return true;
}
if (double_inspect.IsNan()) {
- if (nan_symbol_ == NULL) return false;
+ if (nan_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
result_builder->AddString(nan_symbol_);
return true;
}
@@ -79,7 +79,14 @@ void DoubleToStringConverter::CreateExponentialRepresentation(
StringBuilder* result_builder) const {
DOUBLE_CONVERSION_ASSERT(length != 0);
result_builder->AddCharacter(decimal_digits[0]);
- if (length != 1) {
+ if (length == 1) {
+ if ((flags_ & EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL) != 0) {
+ result_builder->AddCharacter('.');
+ if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL) != 0) {
+ result_builder->AddCharacter('0');
+ }
+ }
+ } else {
result_builder->AddCharacter('.');
result_builder->AddSubstring(&decimal_digits[1], length-1);
}
diff --git a/src/3rdparty/double-conversion/double-conversion/double-to-string.h b/src/3rdparty/double-conversion/double-conversion/double-to-string.h
index 04a4ac3840..abe60e8810 100644
--- a/src/3rdparty/double-conversion/double-conversion/double-to-string.h
+++ b/src/3rdparty/double-conversion/double-conversion/double-to-string.h
@@ -78,7 +78,9 @@ class DoubleToStringConverter {
EMIT_TRAILING_DECIMAL_POINT = 2,
EMIT_TRAILING_ZERO_AFTER_POINT = 4,
UNIQUE_ZERO = 8,
- NO_TRAILING_ZERO = 16
+ NO_TRAILING_ZERO = 16,
+ EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL = 32,
+ EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL = 64
};
// Flags should be a bit-or combination of the possible Flags-enum.
@@ -97,6 +99,13 @@ class DoubleToStringConverter {
// of the result in precision mode. Matches printf's %g.
// When EMIT_TRAILING_ZERO_AFTER_POINT is also given, one trailing zero is
// preserved.
+ // - EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL: when the input number has
+ // exactly one significant digit and is converted into exponent form then a
+ // trailing decimal point is appended to the significand in shortest mode
+ // or in precision mode with one requested digit.
+ // - EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL: in addition to a trailing
+ // decimal point emits a trailing '0'-character. This flag requires the
+ // EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL flag.
//
// Infinity symbol and nan_symbol provide the string representation for these
// special values. If the string is NULL and the special value is encountered
@@ -132,6 +141,22 @@ class DoubleToStringConverter {
// ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT.
// ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
//
+ // When converting numbers with exactly one significant digit to exponent
+ // form in shortest mode or in precision mode with one requested digit, the
+ // EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT flags have
+ // no effect. Use the EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL flag to
+ // append a decimal point in this case and the
+ // EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL flag to also append a
+ // '0'-character in this case.
+ // Example with decimal_in_shortest_low = 0:
+ // ToShortest(0.0009) -> "9e-4"
+ // with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL deactivated.
+ // ToShortest(0.0009) -> "9.e-4"
+ // with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL activated.
+ // ToShortest(0.0009) -> "9.0e-4"
+ // with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL activated and
+ // EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL activated.
+ //
// The min_exponent_width is used for exponential representations.
// The converter adds leading '0's to the exponent until the exponent
// is at least min_exponent_width digits long.
diff --git a/src/3rdparty/double-conversion/double-conversion/string-to-double.cc b/src/3rdparty/double-conversion/double-conversion/string-to-double.cc
index fe633aace7..972956ca69 100644
--- a/src/3rdparty/double-conversion/double-conversion/string-to-double.cc
+++ b/src/3rdparty/double-conversion/double-conversion/string-to-double.cc
@@ -474,7 +474,7 @@ double StringToDoubleConverter::StringToIeee(
current = next_non_space;
}
- if (infinity_symbol_ != NULL) {
+ if (infinity_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensitivity)) {
if (!ConsumeSubString(&current, end, infinity_symbol_, allow_case_insensitivity)) {
return junk_string_value_;
@@ -492,7 +492,7 @@ double StringToDoubleConverter::StringToIeee(
}
}
- if (nan_symbol_ != NULL) {
+ if (nan_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensitivity)) {
if (!ConsumeSubString(&current, end, nan_symbol_, allow_case_insensitivity)) {
return junk_string_value_;
diff --git a/src/3rdparty/double-conversion/double-conversion/utils.h b/src/3rdparty/double-conversion/double-conversion/utils.h
index 41078b6c2c..4f4dd71bf7 100644
--- a/src/3rdparty/double-conversion/double-conversion/utils.h
+++ b/src/3rdparty/double-conversion/double-conversion/utils.h
@@ -34,6 +34,13 @@
#include <cstdlib>
#include <cstring>
+// For pre-C++11 compatibility
+#if __cplusplus >= 201103L
+#define DOUBLE_CONVERSION_NULLPTR nullptr
+#else
+#define DOUBLE_CONVERSION_NULLPTR NULL
+#endif
+
#include <cassert>
#ifndef DOUBLE_CONVERSION_ASSERT
#define DOUBLE_CONVERSION_ASSERT(condition) \
@@ -241,9 +248,9 @@ inline int StrLength(const char* string) {
template <typename T>
class Vector {
public:
- Vector() : start_(NULL), length_(0) {}
+ Vector() : start_(DOUBLE_CONVERSION_NULLPTR), length_(0) {}
Vector(T* data, int len) : start_(data), length_(len) {
- DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL));
+ DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != DOUBLE_CONVERSION_NULLPTR));
}
// Returns a vector using the same backing storage as this one,
@@ -326,7 +333,7 @@ class StringBuilder {
void AddSubstring(const char* s, int n) {
DOUBLE_CONVERSION_ASSERT(!is_finalized() && position_ + n < buffer_.length());
DOUBLE_CONVERSION_ASSERT(static_cast<size_t>(n) <= strlen(s));
- memmove(&buffer_[position_], s, n);
+ memmove(&buffer_[position_], s, static_cast<size_t>(n));
position_ += n;
}