Skip to content

Commit 1fac08e

Browse files
rmacnak-googleCommit Queue
authored andcommitted
Update double-conversion to 7630f84a10f9428b041d0471e71a562141e9684b.
Change-Id: I37d176a938798cb74eae0a3a445182beb55a117d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434900 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 4431536 commit 1fac08e

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

PRESUBMIT.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ def _CheckClangFormat(input_api, output_api):
340340
f.ChangedContents())):
341341
is_deps = True
342342
break
343-
if is_cpp_file(path) and os.path.isfile(path):
343+
if is_cpp_file(path) and os.path.isfile(
344+
path) and not path.startswith('third_party/'):
344345
files.append(path)
345346

346347
if is_deps:

third_party/double-conversion/README.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
URL: https://github.com/google/double-conversion
2-
Version: 032fa6a7d2c319b20d3928f5d762648fa4029acf
2+
Version: 7630f84a10f9428b041d0471e71a562141e9684b
33
License: BSD
44
License File: LICENSE
55

third_party/double-conversion/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ There is extensive documentation in `double-conversion/string-to-double.h` and
1919
Building
2020
========
2121

22-
This library can be built with [scons][0] or [cmake][1].
22+
This library can be built with [scons][0], [cmake][1] or [bazel][2].
2323
The checked-in Makefile simply forwards to scons, and provides a
2424
shortcut to run all tests:
2525

@@ -55,5 +55,23 @@ Use `-DBUILD_TESTING=ON` to build the test executable.
5555
make
5656
test/cctest/cctest
5757

58+
Bazel
59+
---
60+
61+
The simplest way to adopt this library is through the [Bazel Central Registry](https://registry.bazel.build/modules/double-conversion).
62+
63+
To build the library from the latest repository, run:
64+
65+
```
66+
bazel build //:double-conversion
67+
```
68+
69+
To run the unit test, run:
70+
71+
```
72+
bazel test //:cctest
73+
```
74+
5875
[0]: http://www.scons.org/
5976
[1]: https://cmake.org/
77+
[2]: https://bazel.build/

third_party/double-conversion/src/double-to-string.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ bool DoubleToStringConverter::ToShortestIeeeNumber(
180180
return HandleSpecialValues(value, result_builder);
181181
}
182182

183-
int decimal_point;
183+
int decimal_point = 0;
184184
bool sign;
185185
const int kDecimalRepCapacity = kBase10MaximalLength + 1;
186186
char decimal_rep[kDecimalRepCapacity];
@@ -405,6 +405,7 @@ void DoubleToStringConverter::DoubleToAscii(double v,
405405
if (mode == PRECISION && requested_digits == 0) {
406406
vector[0] = '\0';
407407
*length = 0;
408+
*point = 0;
408409
return;
409410
}
410411

third_party/double-conversion/src/double-to-string.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,24 @@ class DoubleToStringConverter {
237237
// kBase10MaximalLength significant digits).
238238
// "-1.7976931348623157e+308", "-1.7976931348623157E308"
239239
// In addition, the buffer must be able to hold the trailing '\0' character.
240+
//
241+
// Since the algorithm finds the shortest number of significant digits, it
242+
// can produce an output that isn't the shortest possible if the
243+
// decimal_in_shortest_high is high enough. For example, the number
244+
// 1e23 could be written as 99999999999999991611392 with 23
245+
// digits, however, it only needs one significant digit 1, and thus the
246+
// result is 100000000000000000000000, which has 24 digits.
240247
bool ToShortest(double value, StringBuilder* result_builder) const {
241248
return ToShortestIeeeNumber(value, result_builder, SHORTEST);
242249
}
243250

244251
// Same as ToShortest, but for single-precision floats.
252+
//
253+
// Since the algorithm finds the shortest number of significant digits, it
254+
// can, in very rare cases, produce an output that isn't the shortest possible.
255+
// For example, the number 1e11f could be written as 99999997952 with 11
256+
// digits, however, it only needs one significant digit 1, and thus the
257+
// result is 100000000000, which has 12 digits.
245258
bool ToShortestSingle(float value, StringBuilder* result_builder) const {
246259
return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE);
247260
}

0 commit comments

Comments
 (0)