12e5b6d6dSopenharmony_ci// Copyright 2010 the V8 project authors. All rights reserved.
22e5b6d6dSopenharmony_ci// Redistribution and use in source and binary forms, with or without
32e5b6d6dSopenharmony_ci// modification, are permitted provided that the following conditions are
42e5b6d6dSopenharmony_ci// met:
52e5b6d6dSopenharmony_ci//
62e5b6d6dSopenharmony_ci//     * Redistributions of source code must retain the above copyright
72e5b6d6dSopenharmony_ci//       notice, this list of conditions and the following disclaimer.
82e5b6d6dSopenharmony_ci//     * Redistributions in binary form must reproduce the above
92e5b6d6dSopenharmony_ci//       copyright notice, this list of conditions and the following
102e5b6d6dSopenharmony_ci//       disclaimer in the documentation and/or other materials provided
112e5b6d6dSopenharmony_ci//       with the distribution.
122e5b6d6dSopenharmony_ci//     * Neither the name of Google Inc. nor the names of its
132e5b6d6dSopenharmony_ci//       contributors may be used to endorse or promote products derived
142e5b6d6dSopenharmony_ci//       from this software without specific prior written permission.
152e5b6d6dSopenharmony_ci//
162e5b6d6dSopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172e5b6d6dSopenharmony_ci// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182e5b6d6dSopenharmony_ci// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192e5b6d6dSopenharmony_ci// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202e5b6d6dSopenharmony_ci// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212e5b6d6dSopenharmony_ci// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222e5b6d6dSopenharmony_ci// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232e5b6d6dSopenharmony_ci// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242e5b6d6dSopenharmony_ci// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252e5b6d6dSopenharmony_ci// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262e5b6d6dSopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272e5b6d6dSopenharmony_ci
282e5b6d6dSopenharmony_ci#include <stdlib.h>
292e5b6d6dSopenharmony_ci
302e5b6d6dSopenharmony_ci
312e5b6d6dSopenharmony_ci#include "cctest.h"
322e5b6d6dSopenharmony_ci#include "double-conversion/fixed-dtoa.h"
332e5b6d6dSopenharmony_ci#include "gay-fixed.h"
342e5b6d6dSopenharmony_ci#include "double-conversion/ieee.h"
352e5b6d6dSopenharmony_ci#include "double-conversion/utils.h"
362e5b6d6dSopenharmony_ci
372e5b6d6dSopenharmony_ciusing namespace double_conversion;
382e5b6d6dSopenharmony_ci
392e5b6d6dSopenharmony_cistatic const int kBufferSize = 500;
402e5b6d6dSopenharmony_ci
412e5b6d6dSopenharmony_ciTEST(FastFixedVariousDoubles) {
422e5b6d6dSopenharmony_ci  char buffer_container[kBufferSize];
432e5b6d6dSopenharmony_ci  Vector<char> buffer(buffer_container, kBufferSize);
442e5b6d6dSopenharmony_ci  int length;
452e5b6d6dSopenharmony_ci  int point;
462e5b6d6dSopenharmony_ci
472e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.0, 1, buffer, &length, &point));
482e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
492e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
502e5b6d6dSopenharmony_ci
512e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.0, 15, buffer, &length, &point));
522e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
532e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
542e5b6d6dSopenharmony_ci
552e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.0, 0, buffer, &length, &point));
562e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
572e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
582e5b6d6dSopenharmony_ci
592e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0xFFFFFFFF, 5, buffer, &length, &point));
602e5b6d6dSopenharmony_ci  CHECK_EQ("4294967295", buffer.start());
612e5b6d6dSopenharmony_ci  CHECK_EQ(10, point);
622e5b6d6dSopenharmony_ci
632e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(4294967296.0, 5, buffer, &length, &point));
642e5b6d6dSopenharmony_ci  CHECK_EQ("4294967296", buffer.start());
652e5b6d6dSopenharmony_ci  CHECK_EQ(10, point);
662e5b6d6dSopenharmony_ci
672e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e21, 5, buffer, &length, &point));
682e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
692e5b6d6dSopenharmony_ci  // CHECK_EQ(22, point);
702e5b6d6dSopenharmony_ci  CHECK_EQ(22, point);
712e5b6d6dSopenharmony_ci
722e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(999999999999999868928.00, 2, buffer, &length, &point));
732e5b6d6dSopenharmony_ci  CHECK_EQ("999999999999999868928", buffer.start());
742e5b6d6dSopenharmony_ci  CHECK_EQ(21, point);
752e5b6d6dSopenharmony_ci
762e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer,
772e5b6d6dSopenharmony_ci                      &length, &point));
782e5b6d6dSopenharmony_ci  CHECK_EQ("6999999999999998951424", buffer.start());
792e5b6d6dSopenharmony_ci  CHECK_EQ(22, point);
802e5b6d6dSopenharmony_ci
812e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.5, 5, buffer, &length, &point));
822e5b6d6dSopenharmony_ci  CHECK_EQ("15", buffer.start());
832e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
842e5b6d6dSopenharmony_ci
852e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.55, 5, buffer, &length, &point));
862e5b6d6dSopenharmony_ci  CHECK_EQ("155", buffer.start());
872e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
882e5b6d6dSopenharmony_ci
892e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.55, 1, buffer, &length, &point));
902e5b6d6dSopenharmony_ci  CHECK_EQ("16", buffer.start());
912e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
922e5b6d6dSopenharmony_ci
932e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.00000001, 15, buffer, &length, &point));
942e5b6d6dSopenharmony_ci  CHECK_EQ("100000001", buffer.start());
952e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
962e5b6d6dSopenharmony_ci
972e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.1, 10, buffer, &length, &point));
982e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
992e5b6d6dSopenharmony_ci  CHECK_EQ(0, point);
1002e5b6d6dSopenharmony_ci
1012e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.01, 10, buffer, &length, &point));
1022e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1032e5b6d6dSopenharmony_ci  CHECK_EQ(-1, point);
1042e5b6d6dSopenharmony_ci
1052e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.001, 10, buffer, &length, &point));
1062e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1072e5b6d6dSopenharmony_ci  CHECK_EQ(-2, point);
1082e5b6d6dSopenharmony_ci
1092e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0001, 10, buffer, &length, &point));
1102e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1112e5b6d6dSopenharmony_ci  CHECK_EQ(-3, point);
1122e5b6d6dSopenharmony_ci
1132e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00001, 10, buffer, &length, &point));
1142e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1152e5b6d6dSopenharmony_ci  CHECK_EQ(-4, point);
1162e5b6d6dSopenharmony_ci
1172e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000001, 10, buffer, &length, &point));
1182e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1192e5b6d6dSopenharmony_ci  CHECK_EQ(-5, point);
1202e5b6d6dSopenharmony_ci
1212e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000001, 10, buffer, &length, &point));
1222e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1232e5b6d6dSopenharmony_ci  CHECK_EQ(-6, point);
1242e5b6d6dSopenharmony_ci
1252e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000001, 10, buffer, &length, &point));
1262e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1272e5b6d6dSopenharmony_ci  CHECK_EQ(-7, point);
1282e5b6d6dSopenharmony_ci
1292e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000001, 10, buffer, &length, &point));
1302e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1312e5b6d6dSopenharmony_ci  CHECK_EQ(-8, point);
1322e5b6d6dSopenharmony_ci
1332e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000001, 15, buffer, &length, &point));
1342e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1352e5b6d6dSopenharmony_ci  CHECK_EQ(-9, point);
1362e5b6d6dSopenharmony_ci
1372e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000000001, 15, buffer, &length, &point));
1382e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1392e5b6d6dSopenharmony_ci  CHECK_EQ(-10, point);
1402e5b6d6dSopenharmony_ci
1412e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000001, 15, buffer, &length, &point));
1422e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1432e5b6d6dSopenharmony_ci  CHECK_EQ(-11, point);
1442e5b6d6dSopenharmony_ci
1452e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000001, 15, buffer, &length, &point));
1462e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1472e5b6d6dSopenharmony_ci  CHECK_EQ(-12, point);
1482e5b6d6dSopenharmony_ci
1492e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000000000001, 15, buffer, &length, &point));
1502e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1512e5b6d6dSopenharmony_ci  CHECK_EQ(-13, point);
1522e5b6d6dSopenharmony_ci
1532e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000001, 20, buffer, &length, &point));
1542e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1552e5b6d6dSopenharmony_ci  CHECK_EQ(-14, point);
1562e5b6d6dSopenharmony_ci
1572e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000000001, 20, buffer, &length, &point));
1582e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1592e5b6d6dSopenharmony_ci  CHECK_EQ(-15, point);
1602e5b6d6dSopenharmony_ci
1612e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000000000000001, 20, buffer, &length, &point));
1622e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1632e5b6d6dSopenharmony_ci  CHECK_EQ(-16, point);
1642e5b6d6dSopenharmony_ci
1652e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000001, 20, buffer, &length, &point));
1662e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1672e5b6d6dSopenharmony_ci  CHECK_EQ(-17, point);
1682e5b6d6dSopenharmony_ci
1692e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000000000001, 20, buffer, &length, &point));
1702e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1712e5b6d6dSopenharmony_ci  CHECK_EQ(-18, point);
1722e5b6d6dSopenharmony_ci
1732e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000000000000000001, 20, buffer, &length, &point));
1742e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1752e5b6d6dSopenharmony_ci  CHECK_EQ(-19, point);
1762e5b6d6dSopenharmony_ci
1772e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.10000000004, 10, buffer, &length, &point));
1782e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1792e5b6d6dSopenharmony_ci  CHECK_EQ(0, point);
1802e5b6d6dSopenharmony_ci
1812e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.01000000004, 10, buffer, &length, &point));
1822e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1832e5b6d6dSopenharmony_ci  CHECK_EQ(-1, point);
1842e5b6d6dSopenharmony_ci
1852e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00100000004, 10, buffer, &length, &point));
1862e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1872e5b6d6dSopenharmony_ci  CHECK_EQ(-2, point);
1882e5b6d6dSopenharmony_ci
1892e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00010000004, 10, buffer, &length, &point));
1902e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1912e5b6d6dSopenharmony_ci  CHECK_EQ(-3, point);
1922e5b6d6dSopenharmony_ci
1932e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00001000004, 10, buffer, &length, &point));
1942e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1952e5b6d6dSopenharmony_ci  CHECK_EQ(-4, point);
1962e5b6d6dSopenharmony_ci
1972e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000100004, 10, buffer, &length, &point));
1982e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
1992e5b6d6dSopenharmony_ci  CHECK_EQ(-5, point);
2002e5b6d6dSopenharmony_ci
2012e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000010004, 10, buffer, &length, &point));
2022e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2032e5b6d6dSopenharmony_ci  CHECK_EQ(-6, point);
2042e5b6d6dSopenharmony_ci
2052e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000001004, 10, buffer, &length, &point));
2062e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2072e5b6d6dSopenharmony_ci  CHECK_EQ(-7, point);
2082e5b6d6dSopenharmony_ci
2092e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000000104, 10, buffer, &length, &point));
2102e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2112e5b6d6dSopenharmony_ci  CHECK_EQ(-8, point);
2122e5b6d6dSopenharmony_ci
2132e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000001000004, 15, buffer, &length, &point));
2142e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2152e5b6d6dSopenharmony_ci  CHECK_EQ(-9, point);
2162e5b6d6dSopenharmony_ci
2172e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000100004, 15, buffer, &length, &point));
2182e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2192e5b6d6dSopenharmony_ci  CHECK_EQ(-10, point);
2202e5b6d6dSopenharmony_ci
2212e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000010004, 15, buffer, &length, &point));
2222e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2232e5b6d6dSopenharmony_ci  CHECK_EQ(-11, point);
2242e5b6d6dSopenharmony_ci
2252e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000001004, 15, buffer, &length, &point));
2262e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2272e5b6d6dSopenharmony_ci  CHECK_EQ(-12, point);
2282e5b6d6dSopenharmony_ci
2292e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000000104, 15, buffer, &length, &point));
2302e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2312e5b6d6dSopenharmony_ci  CHECK_EQ(-13, point);
2322e5b6d6dSopenharmony_ci
2332e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000001000004, 20, buffer, &length, &point));
2342e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2352e5b6d6dSopenharmony_ci  CHECK_EQ(-14, point);
2362e5b6d6dSopenharmony_ci
2372e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000100004, 20, buffer, &length, &point));
2382e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2392e5b6d6dSopenharmony_ci  CHECK_EQ(-15, point);
2402e5b6d6dSopenharmony_ci
2412e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000010004, 20, buffer, &length, &point));
2422e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2432e5b6d6dSopenharmony_ci  CHECK_EQ(-16, point);
2442e5b6d6dSopenharmony_ci
2452e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000001004, 20, buffer, &length, &point));
2462e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2472e5b6d6dSopenharmony_ci  CHECK_EQ(-17, point);
2482e5b6d6dSopenharmony_ci
2492e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000000104, 20, buffer, &length, &point));
2502e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2512e5b6d6dSopenharmony_ci  CHECK_EQ(-18, point);
2522e5b6d6dSopenharmony_ci
2532e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000000014, 20, buffer, &length, &point));
2542e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
2552e5b6d6dSopenharmony_ci  CHECK_EQ(-19, point);
2562e5b6d6dSopenharmony_ci
2572e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.10000000006, 10, buffer, &length, &point));
2582e5b6d6dSopenharmony_ci  CHECK_EQ("1000000001", buffer.start());
2592e5b6d6dSopenharmony_ci  CHECK_EQ(0, point);
2602e5b6d6dSopenharmony_ci
2612e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.01000000006, 10, buffer, &length, &point));
2622e5b6d6dSopenharmony_ci  CHECK_EQ("100000001", buffer.start());
2632e5b6d6dSopenharmony_ci  CHECK_EQ(-1, point);
2642e5b6d6dSopenharmony_ci
2652e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00100000006, 10, buffer, &length, &point));
2662e5b6d6dSopenharmony_ci  CHECK_EQ("10000001", buffer.start());
2672e5b6d6dSopenharmony_ci  CHECK_EQ(-2, point);
2682e5b6d6dSopenharmony_ci
2692e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00010000006, 10, buffer, &length, &point));
2702e5b6d6dSopenharmony_ci  CHECK_EQ("1000001", buffer.start());
2712e5b6d6dSopenharmony_ci  CHECK_EQ(-3, point);
2722e5b6d6dSopenharmony_ci
2732e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00001000006, 10, buffer, &length, &point));
2742e5b6d6dSopenharmony_ci  CHECK_EQ("100001", buffer.start());
2752e5b6d6dSopenharmony_ci  CHECK_EQ(-4, point);
2762e5b6d6dSopenharmony_ci
2772e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000100006, 10, buffer, &length, &point));
2782e5b6d6dSopenharmony_ci  CHECK_EQ("10001", buffer.start());
2792e5b6d6dSopenharmony_ci  CHECK_EQ(-5, point);
2802e5b6d6dSopenharmony_ci
2812e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000010006, 10, buffer, &length, &point));
2822e5b6d6dSopenharmony_ci  CHECK_EQ("1001", buffer.start());
2832e5b6d6dSopenharmony_ci  CHECK_EQ(-6, point);
2842e5b6d6dSopenharmony_ci
2852e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000001006, 10, buffer, &length, &point));
2862e5b6d6dSopenharmony_ci  CHECK_EQ("101", buffer.start());
2872e5b6d6dSopenharmony_ci  CHECK_EQ(-7, point);
2882e5b6d6dSopenharmony_ci
2892e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000000106, 10, buffer, &length, &point));
2902e5b6d6dSopenharmony_ci  CHECK_EQ("11", buffer.start());
2912e5b6d6dSopenharmony_ci  CHECK_EQ(-8, point);
2922e5b6d6dSopenharmony_ci
2932e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000001000006, 15, buffer, &length, &point));
2942e5b6d6dSopenharmony_ci  CHECK_EQ("100001", buffer.start());
2952e5b6d6dSopenharmony_ci  CHECK_EQ(-9, point);
2962e5b6d6dSopenharmony_ci
2972e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000100006, 15, buffer, &length, &point));
2982e5b6d6dSopenharmony_ci  CHECK_EQ("10001", buffer.start());
2992e5b6d6dSopenharmony_ci  CHECK_EQ(-10, point);
3002e5b6d6dSopenharmony_ci
3012e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000010006, 15, buffer, &length, &point));
3022e5b6d6dSopenharmony_ci  CHECK_EQ("1001", buffer.start());
3032e5b6d6dSopenharmony_ci  CHECK_EQ(-11, point);
3042e5b6d6dSopenharmony_ci
3052e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000001006, 15, buffer, &length, &point));
3062e5b6d6dSopenharmony_ci  CHECK_EQ("101", buffer.start());
3072e5b6d6dSopenharmony_ci  CHECK_EQ(-12, point);
3082e5b6d6dSopenharmony_ci
3092e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000000000000106, 15, buffer, &length, &point));
3102e5b6d6dSopenharmony_ci  CHECK_EQ("11", buffer.start());
3112e5b6d6dSopenharmony_ci  CHECK_EQ(-13, point);
3122e5b6d6dSopenharmony_ci
3132e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000001000006, 20, buffer, &length, &point));
3142e5b6d6dSopenharmony_ci  CHECK_EQ("100001", buffer.start());
3152e5b6d6dSopenharmony_ci  CHECK_EQ(-14, point);
3162e5b6d6dSopenharmony_ci
3172e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000100006, 20, buffer, &length, &point));
3182e5b6d6dSopenharmony_ci  CHECK_EQ("10001", buffer.start());
3192e5b6d6dSopenharmony_ci  CHECK_EQ(-15, point);
3202e5b6d6dSopenharmony_ci
3212e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000010006, 20, buffer, &length, &point));
3222e5b6d6dSopenharmony_ci  CHECK_EQ("1001", buffer.start());
3232e5b6d6dSopenharmony_ci  CHECK_EQ(-16, point);
3242e5b6d6dSopenharmony_ci
3252e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000001006, 20, buffer, &length, &point));
3262e5b6d6dSopenharmony_ci  CHECK_EQ("101", buffer.start());
3272e5b6d6dSopenharmony_ci  CHECK_EQ(-17, point);
3282e5b6d6dSopenharmony_ci
3292e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000000106, 20, buffer, &length, &point));
3302e5b6d6dSopenharmony_ci  CHECK_EQ("11", buffer.start());
3312e5b6d6dSopenharmony_ci  CHECK_EQ(-18, point);
3322e5b6d6dSopenharmony_ci
3332e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000000000000000016, 20, buffer, &length, &point));
3342e5b6d6dSopenharmony_ci  CHECK_EQ("2", buffer.start());
3352e5b6d6dSopenharmony_ci  CHECK_EQ(-19, point);
3362e5b6d6dSopenharmony_ci
3372e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.6, 0, buffer, &length, &point));
3382e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3392e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3402e5b6d6dSopenharmony_ci
3412e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.96, 1, buffer, &length, &point));
3422e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3432e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3442e5b6d6dSopenharmony_ci
3452e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.996, 2, buffer, &length, &point));
3462e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3472e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3482e5b6d6dSopenharmony_ci
3492e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.9996, 3, buffer, &length, &point));
3502e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3512e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3522e5b6d6dSopenharmony_ci
3532e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.99996, 4, buffer, &length, &point));
3542e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3552e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3562e5b6d6dSopenharmony_ci
3572e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.999996, 5, buffer, &length, &point));
3582e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3592e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3602e5b6d6dSopenharmony_ci
3612e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.9999996, 6, buffer, &length, &point));
3622e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3632e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3642e5b6d6dSopenharmony_ci
3652e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.99999996, 7, buffer, &length, &point));
3662e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3672e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3682e5b6d6dSopenharmony_ci
3692e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.999999996, 8, buffer, &length, &point));
3702e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3712e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3722e5b6d6dSopenharmony_ci
3732e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.9999999996, 9, buffer, &length, &point));
3742e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3752e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3762e5b6d6dSopenharmony_ci
3772e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.99999999996, 10, buffer, &length, &point));
3782e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3792e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3802e5b6d6dSopenharmony_ci
3812e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.999999999996, 11, buffer, &length, &point));
3822e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3832e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3842e5b6d6dSopenharmony_ci
3852e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.9999999999996, 12, buffer, &length, &point));
3862e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3872e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3882e5b6d6dSopenharmony_ci
3892e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.99999999999996, 13, buffer, &length, &point));
3902e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3912e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3922e5b6d6dSopenharmony_ci
3932e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.999999999999996, 14, buffer, &length, &point));
3942e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3952e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
3962e5b6d6dSopenharmony_ci
3972e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.9999999999999996, 15, buffer, &length, &point));
3982e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
3992e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
4002e5b6d6dSopenharmony_ci
4012e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00999999999999996, 16, buffer, &length, &point));
4022e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4032e5b6d6dSopenharmony_ci  CHECK_EQ(-1, point);
4042e5b6d6dSopenharmony_ci
4052e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000999999999999996, 17, buffer, &length, &point));
4062e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4072e5b6d6dSopenharmony_ci  CHECK_EQ(-2, point);
4082e5b6d6dSopenharmony_ci
4092e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.0000999999999999996, 18, buffer, &length, &point));
4102e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4112e5b6d6dSopenharmony_ci  CHECK_EQ(-3, point);
4122e5b6d6dSopenharmony_ci
4132e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.00000999999999999996, 19, buffer, &length, &point));
4142e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4152e5b6d6dSopenharmony_ci  CHECK_EQ(-4, point);
4162e5b6d6dSopenharmony_ci
4172e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.000000999999999999996, 20, buffer, &length, &point));
4182e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4192e5b6d6dSopenharmony_ci  CHECK_EQ(-5, point);
4202e5b6d6dSopenharmony_ci
4212e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(323423.234234, 10, buffer, &length, &point));
4222e5b6d6dSopenharmony_ci  CHECK_EQ("323423234234", buffer.start());
4232e5b6d6dSopenharmony_ci  CHECK_EQ(6, point);
4242e5b6d6dSopenharmony_ci
4252e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(12345678.901234, 4, buffer, &length, &point));
4262e5b6d6dSopenharmony_ci  CHECK_EQ("123456789012", buffer.start());
4272e5b6d6dSopenharmony_ci  CHECK_EQ(8, point);
4282e5b6d6dSopenharmony_ci
4292e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(98765.432109, 5, buffer, &length, &point));
4302e5b6d6dSopenharmony_ci  CHECK_EQ("9876543211", buffer.start());
4312e5b6d6dSopenharmony_ci  CHECK_EQ(5, point);
4322e5b6d6dSopenharmony_ci
4332e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(42, 20, buffer, &length, &point));
4342e5b6d6dSopenharmony_ci  CHECK_EQ("42", buffer.start());
4352e5b6d6dSopenharmony_ci  CHECK_EQ(2, point);
4362e5b6d6dSopenharmony_ci
4372e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(0.5, 0, buffer, &length, &point));
4382e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4392e5b6d6dSopenharmony_ci  CHECK_EQ(1, point);
4402e5b6d6dSopenharmony_ci
4412e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e-23, 10, buffer, &length, &point));
4422e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4432e5b6d6dSopenharmony_ci  CHECK_EQ(-10, point);
4442e5b6d6dSopenharmony_ci
4452e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e-123, 2, buffer, &length, &point));
4462e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4472e5b6d6dSopenharmony_ci  CHECK_EQ(-2, point);
4482e5b6d6dSopenharmony_ci
4492e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e-123, 0, buffer, &length, &point));
4502e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4512e5b6d6dSopenharmony_ci  CHECK_EQ(0, point);
4522e5b6d6dSopenharmony_ci
4532e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e-23, 20, buffer, &length, &point));
4542e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4552e5b6d6dSopenharmony_ci  CHECK_EQ(-20, point);
4562e5b6d6dSopenharmony_ci
4572e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e-21, 20, buffer, &length, &point));
4582e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4592e5b6d6dSopenharmony_ci  CHECK_EQ(-20, point);
4602e5b6d6dSopenharmony_ci
4612e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1e-22, 20, buffer, &length, &point));
4622e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4632e5b6d6dSopenharmony_ci  CHECK_EQ(-20, point);
4642e5b6d6dSopenharmony_ci
4652e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(6e-21, 20, buffer, &length, &point));
4662e5b6d6dSopenharmony_ci  CHECK_EQ("1", buffer.start());
4672e5b6d6dSopenharmony_ci  CHECK_EQ(-19, point);
4682e5b6d6dSopenharmony_ci
4692e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(9.1193616301674545152000000e+19, 0,
4702e5b6d6dSopenharmony_ci                      buffer, &length, &point));
4712e5b6d6dSopenharmony_ci  CHECK_EQ("91193616301674545152", buffer.start());
4722e5b6d6dSopenharmony_ci  CHECK_EQ(20, point);
4732e5b6d6dSopenharmony_ci
4742e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(4.8184662102767651659096515e-04, 19,
4752e5b6d6dSopenharmony_ci                      buffer, &length, &point));
4762e5b6d6dSopenharmony_ci  CHECK_EQ("4818466210276765", buffer.start());
4772e5b6d6dSopenharmony_ci  CHECK_EQ(-3, point);
4782e5b6d6dSopenharmony_ci
4792e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1.9023164229540652612705182e-23, 8,
4802e5b6d6dSopenharmony_ci                      buffer, &length, &point));
4812e5b6d6dSopenharmony_ci  CHECK_EQ("", buffer.start());
4822e5b6d6dSopenharmony_ci  CHECK_EQ(-8, point);
4832e5b6d6dSopenharmony_ci
4842e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(1000000000000000128.0, 0,
4852e5b6d6dSopenharmony_ci                      buffer, &length, &point));
4862e5b6d6dSopenharmony_ci  CHECK_EQ("1000000000000000128", buffer.start());
4872e5b6d6dSopenharmony_ci  CHECK_EQ(19, point);
4882e5b6d6dSopenharmony_ci
4892e5b6d6dSopenharmony_ci  CHECK(FastFixedDtoa(2.10861548515811875e+15, 17, buffer, &length, &point));
4902e5b6d6dSopenharmony_ci  CHECK_EQ("210861548515811875", buffer.start());
4912e5b6d6dSopenharmony_ci  CHECK_EQ(16, point);
4922e5b6d6dSopenharmony_ci}
4932e5b6d6dSopenharmony_ci
4942e5b6d6dSopenharmony_ci
4952e5b6d6dSopenharmony_ciTEST(FastFixedDtoaGayFixed) {
4962e5b6d6dSopenharmony_ci  char buffer_container[kBufferSize];
4972e5b6d6dSopenharmony_ci  Vector<char> buffer(buffer_container, kBufferSize);
4982e5b6d6dSopenharmony_ci  bool status;
4992e5b6d6dSopenharmony_ci  int length;
5002e5b6d6dSopenharmony_ci  int point;
5012e5b6d6dSopenharmony_ci
5022e5b6d6dSopenharmony_ci  Vector<const PrecomputedFixed> precomputed =
5032e5b6d6dSopenharmony_ci      PrecomputedFixedRepresentations();
5042e5b6d6dSopenharmony_ci  for (int i = 0; i < precomputed.length(); ++i) {
5052e5b6d6dSopenharmony_ci    const PrecomputedFixed current_test = precomputed[i];
5062e5b6d6dSopenharmony_ci    double v = current_test.v;
5072e5b6d6dSopenharmony_ci    int number_digits = current_test.number_digits;
5082e5b6d6dSopenharmony_ci    status = FastFixedDtoa(v, number_digits,
5092e5b6d6dSopenharmony_ci                           buffer, &length, &point);
5102e5b6d6dSopenharmony_ci    CHECK(status);
5112e5b6d6dSopenharmony_ci    CHECK_EQ(current_test.decimal_point, point);
5122e5b6d6dSopenharmony_ci    CHECK(number_digits >= length - point);
5132e5b6d6dSopenharmony_ci    CHECK_EQ(current_test.representation, buffer.start());
5142e5b6d6dSopenharmony_ci  }
5152e5b6d6dSopenharmony_ci}
516