15 using namespace v8::internal;
17 static const int kBufferSize = 100;
21 static void TrimRepresentation(
Vector<char> representation) {
24 for (i = len - 1; i >= 0; --i) {
25 if (representation[i] !=
'0')
break;
27 representation[i + 1] =
'\0';
31 TEST(FastDtoaShortestVariousDoubles) {
32 char buffer_container[kBufferSize];
38 double min_double = 5e-324;
40 buffer, &length, &point);
45 double max_double = 1.7976931348623157e308;
47 buffer, &length, &point);
53 buffer, &length, &point);
59 buffer, &length, &point);
65 buffer, &length, &point);
71 buffer, &length, &point);
77 buffer, &length, &point);
101 TEST(FastDtoaPrecisionVariousDoubles) {
102 char buffer_container[kBufferSize];
111 TrimRepresentation(buffer);
118 TrimRepresentation(buffer);
123 double min_double = 5e-324;
125 buffer, &length, &point);
130 double max_double = 1.7976931348623157e308;
132 buffer, &length, &point);
138 buffer, &length, &point);
141 TrimRepresentation(buffer);
147 buffer, &length, &point);
153 buffer, &length, &point);
159 buffer, &length, &point);
165 buffer, &length, &point);
168 TrimRepresentation(buffer);
184 TrimRepresentation(buffer);
188 v = 3.3161339052167390562200598e-237;
194 v = 7.9885183916008099497815232e+191;
203 char buffer_container[kBufferSize];
210 bool needed_max_length =
false;
214 for (
int i = 0; i < precomputed.
length(); ++i) {
217 double v = current_test.
v;
220 if (!status)
continue;
226 CHECK_GT(succeeded*1.0/total, 0.99);
227 CHECK(needed_max_length);
232 char buffer_container[kBufferSize];
240 int succeeded_15 = 0;
245 for (
int i = 0; i < precomputed.
length(); ++i) {
247 double v = current_test.
v;
250 if (number_digits <= 15) total_15++;
252 buffer, &length, &point);
254 if (!status)
continue;
256 if (number_digits <= 15) succeeded_15++;
257 TrimRepresentation(buffer);
264 CHECK_GT(succeeded*1.0/total, 0.85);
267 CHECK_GT(succeeded_15*1.0/total_15, 0.9999);
const int kFastDtoaMaximalLength
#define CHECK_EQ(expected, value)
Vector< const PrecomputedShortest > PrecomputedShortestRepresentations()
Vector< const PrecomputedPrecision > PrecomputedPrecisionRepresentations()
const char * representation
bool FastDtoa(double v, FastDtoaMode mode, int requested_digits, Vector< char > buffer, int *length, int *decimal_point)
const char * representation
#define V8_2PART_UINT64_C(a, b)
int StrLength(const char *string)