40 using namespace v8::internal;
42 static const int kBufferSize = 100;
46 static void TrimRepresentation(
Vector<char> representation) {
49 for (i = len - 1; i >= 0; --i) {
50 if (representation[i] !=
'0')
break;
52 representation[i + 1] =
'\0';
56 TEST(FastDtoaShortestVariousDoubles) {
57 char buffer_container[kBufferSize];
63 double min_double = 5e-324;
65 buffer, &length, &point);
70 double max_double = 1.7976931348623157e308;
72 buffer, &length, &point);
78 buffer, &length, &point);
84 buffer, &length, &point);
90 buffer, &length, &point);
96 buffer, &length, &point);
102 buffer, &length, &point);
126 TEST(FastDtoaPrecisionVariousDoubles) {
127 char buffer_container[kBufferSize];
136 TrimRepresentation(buffer);
143 TrimRepresentation(buffer);
148 double min_double = 5e-324;
150 buffer, &length, &point);
155 double max_double = 1.7976931348623157e308;
157 buffer, &length, &point);
163 buffer, &length, &point);
166 TrimRepresentation(buffer);
172 buffer, &length, &point);
178 buffer, &length, &point);
184 buffer, &length, &point);
190 buffer, &length, &point);
193 TrimRepresentation(buffer);
209 TrimRepresentation(buffer);
213 v = 3.3161339052167390562200598e-237;
219 v = 7.9885183916008099497815232e+191;
228 char buffer_container[kBufferSize];
235 bool needed_max_length =
false;
239 for (
int i = 0; i < precomputed.
length(); ++i) {
242 double v = current_test.
v;
245 if (!status)
continue;
251 CHECK_GT(succeeded*1.0/total, 0.99);
252 CHECK(needed_max_length);
257 char buffer_container[kBufferSize];
265 int succeeded_15 = 0;
270 for (
int i = 0; i < precomputed.
length(); ++i) {
272 double v = current_test.
v;
275 if (number_digits <= 15) total_15++;
277 buffer, &length, &point);
279 if (!status)
continue;
281 if (number_digits <= 15) succeeded_15++;
282 TrimRepresentation(buffer);
289 CHECK_GT(succeeded*1.0/total, 0.85);
292 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)