OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "platform.h" | 7 #include "platform.h" |
8 #include "cctest.h" | 8 #include "cctest.h" |
9 #include "diy-fp.h" | 9 #include "diy-fp.h" |
10 #include "double.h" | 10 #include "double.h" |
11 #include "fast-dtoa.h" | 11 #include "fast-dtoa.h" |
12 #include "gay-precision.h" | 12 #include "gay-precision.h" |
13 #include "gay-shortest.h" | 13 #include "gay-shortest.h" |
14 | 14 |
15 using namespace v8::internal; | 15 using namespace v8::internal; |
16 | 16 |
17 static const int kBufferSize = 100; | 17 static const int kBufferSize = 100; |
18 | 18 |
19 | 19 |
20 // Removes trailing '0' digits. | 20 // Removes trailing '0' digits. |
21 static void TrimRepresentation(Vector<char> representation) { | 21 static void TrimRepresentation(Vector<char> representation) { |
22 int len = strlen(representation.start()); | 22 int len = StrLength(representation.start()); |
23 int i; | 23 int i; |
24 for (i = len - 1; i >= 0; --i) { | 24 for (i = len - 1; i >= 0; --i) { |
25 if (representation[i] != '0') break; | 25 if (representation[i] != '0') break; |
26 } | 26 } |
27 representation[i + 1] = '\0'; | 27 representation[i + 1] = '\0'; |
28 } | 28 } |
29 | 29 |
30 | 30 |
31 TEST(FastDtoaShortestVariousDoubles) { | 31 TEST(FastDtoaShortestVariousDoubles) { |
32 char buffer_container[kBufferSize]; | 32 char buffer_container[kBufferSize]; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 CHECK_EQ(current_test.representation, buffer.start()); | 259 CHECK_EQ(current_test.representation, buffer.start()); |
260 } | 260 } |
261 // The precomputed numbers contain many entries with many requested | 261 // The precomputed numbers contain many entries with many requested |
262 // digits. These have a high failure rate and we therefore expect a lower | 262 // digits. These have a high failure rate and we therefore expect a lower |
263 // success rate than for the shortest representation. | 263 // success rate than for the shortest representation. |
264 CHECK_GT(succeeded*1.0/total, 0.85); | 264 CHECK_GT(succeeded*1.0/total, 0.85); |
265 // However with less than 15 digits almost the algorithm should almost always | 265 // However with less than 15 digits almost the algorithm should almost always |
266 // succeed. | 266 // succeed. |
267 CHECK_GT(succeeded_15*1.0/total_15, 0.9999); | 267 CHECK_GT(succeeded_15*1.0/total_15, 0.9999); |
268 } | 268 } |
OLD | NEW |