Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | #include "src/v8.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 31 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 32 | #include "src/base/platform/platform.h" |
| 33 | #include "src/diy-fp.h" |
| 34 | #include "src/double.h" |
| 35 | #include "src/fast-dtoa.h" |
| 36 | #include "test/cctest/cctest.h" |
| 37 | #include "test/cctest/gay-precision.h" |
| 38 | #include "test/cctest/gay-shortest.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 39 | |
| 40 | using namespace v8::internal; |
| 41 | |
| 42 | static const int kBufferSize = 100; |
| 43 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 44 | |
| 45 | // Removes trailing '0' digits. |
| 46 | static void TrimRepresentation(Vector<char> representation) { |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 47 | int len = StrLength(representation.start()); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 48 | int i; |
| 49 | for (i = len - 1; i >= 0; --i) { |
| 50 | if (representation[i] != '0') break; |
| 51 | } |
| 52 | representation[i + 1] = '\0'; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | TEST(FastDtoaShortestVariousDoubles) { |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 57 | char buffer_container[kBufferSize]; |
| 58 | Vector<char> buffer(buffer_container, kBufferSize); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 59 | int length; |
| 60 | int point; |
| 61 | int status; |
| 62 | |
| 63 | double min_double = 5e-324; |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 64 | status = FastDtoa(min_double, FAST_DTOA_SHORTEST, 0, |
| 65 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 66 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 67 | CHECK_EQ(0, strcmp("5", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 68 | CHECK_EQ(-323, point); |
| 69 | |
| 70 | double max_double = 1.7976931348623157e308; |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 71 | status = FastDtoa(max_double, FAST_DTOA_SHORTEST, 0, |
| 72 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 73 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 74 | CHECK_EQ(0, strcmp("17976931348623157", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 75 | CHECK_EQ(309, point); |
| 76 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 77 | status = FastDtoa(4294967272.0, FAST_DTOA_SHORTEST, 0, |
| 78 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 79 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 80 | CHECK_EQ(0, strcmp("4294967272", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 81 | CHECK_EQ(10, point); |
| 82 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 83 | status = FastDtoa(4.1855804968213567e298, FAST_DTOA_SHORTEST, 0, |
| 84 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 85 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 86 | CHECK_EQ(0, strcmp("4185580496821357", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 87 | CHECK_EQ(299, point); |
| 88 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 89 | status = FastDtoa(5.5626846462680035e-309, FAST_DTOA_SHORTEST, 0, |
| 90 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 91 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 92 | CHECK_EQ(0, strcmp("5562684646268003", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 93 | CHECK_EQ(-308, point); |
| 94 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 95 | status = FastDtoa(2147483648.0, FAST_DTOA_SHORTEST, 0, |
| 96 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 97 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 98 | CHECK_EQ(0, strcmp("2147483648", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 99 | CHECK_EQ(10, point); |
| 100 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 101 | status = FastDtoa(3.5844466002796428e+298, FAST_DTOA_SHORTEST, 0, |
| 102 | buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 103 | if (status) { // Not all FastDtoa variants manage to compute this number. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 104 | CHECK_EQ(0, strcmp("35844466002796428", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 105 | CHECK_EQ(299, point); |
| 106 | } |
| 107 | |
| 108 | uint64_t smallest_normal64 = V8_2PART_UINT64_C(0x00100000, 00000000); |
| 109 | double v = Double(smallest_normal64).value(); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 110 | status = FastDtoa(v, FAST_DTOA_SHORTEST, 0, buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 111 | if (status) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 112 | CHECK_EQ(0, strcmp("22250738585072014", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 113 | CHECK_EQ(-307, point); |
| 114 | } |
| 115 | |
| 116 | uint64_t largest_denormal64 = V8_2PART_UINT64_C(0x000FFFFF, FFFFFFFF); |
| 117 | v = Double(largest_denormal64).value(); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 118 | status = FastDtoa(v, FAST_DTOA_SHORTEST, 0, buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 119 | if (status) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 120 | CHECK_EQ(0, strcmp("2225073858507201", buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 121 | CHECK_EQ(-307, point); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 126 | TEST(FastDtoaPrecisionVariousDoubles) { |
| 127 | char buffer_container[kBufferSize]; |
| 128 | Vector<char> buffer(buffer_container, kBufferSize); |
| 129 | int length; |
| 130 | int point; |
| 131 | int status; |
| 132 | |
| 133 | status = FastDtoa(1.0, FAST_DTOA_PRECISION, 3, buffer, &length, &point); |
| 134 | CHECK(status); |
| 135 | CHECK_GE(3, length); |
| 136 | TrimRepresentation(buffer); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 137 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 138 | CHECK_EQ(1, point); |
| 139 | |
| 140 | status = FastDtoa(1.5, FAST_DTOA_PRECISION, 10, buffer, &length, &point); |
| 141 | if (status) { |
| 142 | CHECK_GE(10, length); |
| 143 | TrimRepresentation(buffer); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 144 | CHECK_EQ(0, strcmp("15", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 145 | CHECK_EQ(1, point); |
| 146 | } |
| 147 | |
| 148 | double min_double = 5e-324; |
| 149 | status = FastDtoa(min_double, FAST_DTOA_PRECISION, 5, |
| 150 | buffer, &length, &point); |
| 151 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 152 | CHECK_EQ(0, strcmp("49407", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 153 | CHECK_EQ(-323, point); |
| 154 | |
| 155 | double max_double = 1.7976931348623157e308; |
| 156 | status = FastDtoa(max_double, FAST_DTOA_PRECISION, 7, |
| 157 | buffer, &length, &point); |
| 158 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 159 | CHECK_EQ(0, strcmp("1797693", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 160 | CHECK_EQ(309, point); |
| 161 | |
| 162 | status = FastDtoa(4294967272.0, FAST_DTOA_PRECISION, 14, |
| 163 | buffer, &length, &point); |
| 164 | if (status) { |
| 165 | CHECK_GE(14, length); |
| 166 | TrimRepresentation(buffer); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 167 | CHECK_EQ(0, strcmp("4294967272", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 168 | CHECK_EQ(10, point); |
| 169 | } |
| 170 | |
| 171 | status = FastDtoa(4.1855804968213567e298, FAST_DTOA_PRECISION, 17, |
| 172 | buffer, &length, &point); |
| 173 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 174 | CHECK_EQ(0, strcmp("41855804968213567", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 175 | CHECK_EQ(299, point); |
| 176 | |
| 177 | status = FastDtoa(5.5626846462680035e-309, FAST_DTOA_PRECISION, 1, |
| 178 | buffer, &length, &point); |
| 179 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 180 | CHECK_EQ(0, strcmp("6", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 181 | CHECK_EQ(-308, point); |
| 182 | |
| 183 | status = FastDtoa(2147483648.0, FAST_DTOA_PRECISION, 5, |
| 184 | buffer, &length, &point); |
| 185 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 186 | CHECK_EQ(0, strcmp("21475", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 187 | CHECK_EQ(10, point); |
| 188 | |
| 189 | status = FastDtoa(3.5844466002796428e+298, FAST_DTOA_PRECISION, 10, |
| 190 | buffer, &length, &point); |
| 191 | CHECK(status); |
| 192 | CHECK_GE(10, length); |
| 193 | TrimRepresentation(buffer); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 194 | CHECK_EQ(0, strcmp("35844466", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 195 | CHECK_EQ(299, point); |
| 196 | |
| 197 | uint64_t smallest_normal64 = V8_2PART_UINT64_C(0x00100000, 00000000); |
| 198 | double v = Double(smallest_normal64).value(); |
| 199 | status = FastDtoa(v, FAST_DTOA_PRECISION, 17, buffer, &length, &point); |
| 200 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 201 | CHECK_EQ(0, strcmp("22250738585072014", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 202 | CHECK_EQ(-307, point); |
| 203 | |
| 204 | uint64_t largest_denormal64 = V8_2PART_UINT64_C(0x000FFFFF, FFFFFFFF); |
| 205 | v = Double(largest_denormal64).value(); |
| 206 | status = FastDtoa(v, FAST_DTOA_PRECISION, 17, buffer, &length, &point); |
| 207 | CHECK(status); |
| 208 | CHECK_GE(20, length); |
| 209 | TrimRepresentation(buffer); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 210 | CHECK_EQ(0, strcmp("22250738585072009", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 211 | CHECK_EQ(-307, point); |
| 212 | |
| 213 | v = 3.3161339052167390562200598e-237; |
| 214 | status = FastDtoa(v, FAST_DTOA_PRECISION, 18, buffer, &length, &point); |
| 215 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 216 | CHECK_EQ(0, strcmp("331613390521673906", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 217 | CHECK_EQ(-236, point); |
| 218 | |
| 219 | v = 7.9885183916008099497815232e+191; |
| 220 | status = FastDtoa(v, FAST_DTOA_PRECISION, 4, buffer, &length, &point); |
| 221 | CHECK(status); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 222 | CHECK_EQ(0, strcmp("7989", buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 223 | CHECK_EQ(192, point); |
| 224 | } |
| 225 | |
| 226 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 227 | TEST(FastDtoaGayShortest) { |
| 228 | char buffer_container[kBufferSize]; |
| 229 | Vector<char> buffer(buffer_container, kBufferSize); |
| 230 | bool status; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 231 | int length; |
| 232 | int point; |
| 233 | int succeeded = 0; |
| 234 | int total = 0; |
| 235 | bool needed_max_length = false; |
| 236 | |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 237 | Vector<const PrecomputedShortest> precomputed = |
| 238 | PrecomputedShortestRepresentations(); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 239 | for (int i = 0; i < precomputed.length(); ++i) { |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 240 | const PrecomputedShortest current_test = precomputed[i]; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 241 | total++; |
| 242 | double v = current_test.v; |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 243 | status = FastDtoa(v, FAST_DTOA_SHORTEST, 0, buffer, &length, &point); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 244 | CHECK_GE(kFastDtoaMaximalLength, length); |
| 245 | if (!status) continue; |
| 246 | if (length == kFastDtoaMaximalLength) needed_max_length = true; |
| 247 | succeeded++; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 248 | CHECK_EQ(current_test.decimal_point, point); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 249 | CHECK_EQ(0, strcmp(current_test.representation, buffer.start())); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 250 | } |
| 251 | CHECK_GT(succeeded*1.0/total, 0.99); |
| 252 | CHECK(needed_max_length); |
| 253 | } |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 254 | |
| 255 | |
| 256 | TEST(FastDtoaGayPrecision) { |
| 257 | char buffer_container[kBufferSize]; |
| 258 | Vector<char> buffer(buffer_container, kBufferSize); |
| 259 | bool status; |
| 260 | int length; |
| 261 | int point; |
| 262 | int succeeded = 0; |
| 263 | int total = 0; |
| 264 | // Count separately for entries with less than 15 requested digits. |
| 265 | int succeeded_15 = 0; |
| 266 | int total_15 = 0; |
| 267 | |
| 268 | Vector<const PrecomputedPrecision> precomputed = |
| 269 | PrecomputedPrecisionRepresentations(); |
| 270 | for (int i = 0; i < precomputed.length(); ++i) { |
| 271 | const PrecomputedPrecision current_test = precomputed[i]; |
| 272 | double v = current_test.v; |
| 273 | int number_digits = current_test.number_digits; |
| 274 | total++; |
| 275 | if (number_digits <= 15) total_15++; |
| 276 | status = FastDtoa(v, FAST_DTOA_PRECISION, number_digits, |
| 277 | buffer, &length, &point); |
| 278 | CHECK_GE(number_digits, length); |
| 279 | if (!status) continue; |
| 280 | succeeded++; |
| 281 | if (number_digits <= 15) succeeded_15++; |
| 282 | TrimRepresentation(buffer); |
| 283 | CHECK_EQ(current_test.decimal_point, point); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 284 | CHECK_EQ(0, strcmp(current_test.representation, buffer.start())); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 285 | } |
| 286 | // The precomputed numbers contain many entries with many requested |
| 287 | // digits. These have a high failure rate and we therefore expect a lower |
| 288 | // success rate than for the shortest representation. |
| 289 | CHECK_GT(succeeded*1.0/total, 0.85); |
| 290 | // However with less than 15 digits almost the algorithm should almost always |
| 291 | // succeed. |
| 292 | CHECK_GT(succeeded_15*1.0/total_15, 0.9999); |
| 293 | } |