diff options
author | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-08-29 11:18:16 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-09-01 23:07:06 +0100 |
commit | 4ad510a63fd88b7907b2a1b8feceace9758397d0 (patch) | |
tree | 689ae8fabb960a1a452944b2647f1b9279b6e7a5 /meta | |
parent | 8ebdd79442e8719721567160c1f56e4ccf6b1cf7 (diff) | |
download | poky-4ad510a63fd88b7907b2a1b8feceace9758397d0.tar.gz |
vte: upgrade 0.78.2 -> 0.80.3
0004-fast_float-Add-single-header-library-for-from_char-i.patch
and 0005-color-parser-Use-fast_float-implementation-for-from_.patch
patches dropped: upstream has adopted the changes, and oe-core also
provides now fastfloat, no need to vendor it with a patch.
0002-lib-Typo-fix.patch is dropped, because it was a backport, and
it is included in this release.
Shortlog: https://gitlab.gnome.org/GNOME/vte/-/compare/0.80.3...0.78.2
(From OE-Core rev: 0a849dc7edeecb6c16a8a0fe347015d6d85e9dfd)
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-support/vte/vte/0002-lib-Typo-fix.patch | 25 | ||||
-rw-r--r-- | meta/recipes-support/vte/vte/0004-fast_float-Add-single-header-library-for-from_char-i.patch | 3922 | ||||
-rw-r--r-- | meta/recipes-support/vte/vte/0005-color-parser-Use-fast_float-implementation-for-from_.patch | 102 | ||||
-rw-r--r-- | meta/recipes-support/vte/vte_0.80.3.bb (renamed from meta/recipes-support/vte/vte_0.78.2.bb) | 14 |
4 files changed, 6 insertions, 4057 deletions
diff --git a/meta/recipes-support/vte/vte/0002-lib-Typo-fix.patch b/meta/recipes-support/vte/vte/0002-lib-Typo-fix.patch deleted file mode 100644 index 410d506806..0000000000 --- a/meta/recipes-support/vte/vte/0002-lib-Typo-fix.patch +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | From 6b7440996819c12ec32bfaf4e73b27baeb273207 Mon Sep 17 00:00:00 2001 | ||
2 | From: Christian Persch <chpe@src.gnome.org> | ||
3 | Date: Thu, 5 Sep 2024 23:59:05 +0200 | ||
4 | Subject: [PATCH 2/3] lib: Typo fix | ||
5 | |||
6 | Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2816 | ||
7 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/vte/-/commit/e24087d953d9352c8bc46074e2662c80f9bfbc2d] | ||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | src/vteinternal.hh | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/src/vteinternal.hh b/src/vteinternal.hh | ||
14 | index 051e78c..b1adc19 100644 | ||
15 | --- a/src/vteinternal.hh | ||
16 | +++ b/src/vteinternal.hh | ||
17 | @@ -1233,7 +1233,7 @@ public: | ||
18 | void reset_decoder(); | ||
19 | |||
20 | void feed(std::string_view const& data, | ||
21 | - bool start_processsing_ = true); | ||
22 | + bool start_processing_ = true); | ||
23 | void feed_child(char const* data, | ||
24 | size_t length) { assert(data); feed_child({data, length}); } | ||
25 | void feed_child(std::string_view const& str); | ||
diff --git a/meta/recipes-support/vte/vte/0004-fast_float-Add-single-header-library-for-from_char-i.patch b/meta/recipes-support/vte/vte/0004-fast_float-Add-single-header-library-for-from_char-i.patch deleted file mode 100644 index 731dba729d..0000000000 --- a/meta/recipes-support/vte/vte/0004-fast_float-Add-single-header-library-for-from_char-i.patch +++ /dev/null | |||
@@ -1,3922 +0,0 @@ | |||
1 | From 2a32e43e43b04771a3357d3d4ccbafa7714e0114 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 4 Oct 2024 21:21:11 -0700 | ||
4 | Subject: [PATCH 4/5] fast_float: Add single header library for from_char | ||
5 | implementation | ||
6 | |||
7 | Document the process to re-generate the file whenever new release | ||
8 | is made for fast_float upstream. | ||
9 | |||
10 | This would make it work with llvm libc++ | ||
11 | |||
12 | Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/vte/-/issues/2823#note_2239888] | ||
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
14 | --- | ||
15 | README.md | 17 + | ||
16 | src/fast_float.hh | 3869 +++++++++++++++++++++++++++++++++++++++++++++ | ||
17 | 2 files changed, 3886 insertions(+) | ||
18 | create mode 100644 src/fast_float.hh | ||
19 | |||
20 | diff --git a/README.md b/README.md | ||
21 | index a32465a9..20ed5ba2 100644 | ||
22 | --- a/README.md | ||
23 | +++ b/README.md | ||
24 | @@ -21,6 +21,23 @@ on download.gnome.org, but please note that any tarball for releases | ||
25 | after 0.60.3 were made by either the gnome release team or other | ||
26 | gnome contributors, but not by a VTE maintainer. | ||
27 | |||
28 | +fast_float library[1] is used to provide from_chars implementation for faster | ||
29 | +and more portable parsing of 64 decimal strings. | ||
30 | + | ||
31 | +fast_float.hh is an amalgamation of the entire library, | ||
32 | +which can be regenerated by using amalgamate.py script provided by | ||
33 | +fast_float repository. Following command can be used to re-generate the | ||
34 | +header file | ||
35 | + | ||
36 | +``` | ||
37 | +git clone https://github.com/fastfloat/fast_float | ||
38 | +cd fast_float | ||
39 | +git checkout v6.1.6 | ||
40 | +python3 ./script/amalgamate.py --license=MIT > $VTE_SRC/src/fast_float.hh | ||
41 | +``` | ||
42 | + | ||
43 | +[1]: https://github.com/fastfloat/fast_float | ||
44 | + | ||
45 | Installation | ||
46 | ------------ | ||
47 | |||
48 | diff --git a/src/fast_float.hh b/src/fast_float.hh | ||
49 | new file mode 100644 | ||
50 | index 00000000..e0d5dd53 | ||
51 | --- /dev/null | ||
52 | +++ b/src/fast_float.hh | ||
53 | @@ -0,0 +1,3869 @@ | ||
54 | +// fast_float by Daniel Lemire | ||
55 | +// fast_float by João Paulo Magalhaes | ||
56 | +// | ||
57 | +// | ||
58 | +// with contributions from Eugene Golushkov | ||
59 | +// with contributions from Maksim Kita | ||
60 | +// with contributions from Marcin Wojdyr | ||
61 | +// with contributions from Neal Richardson | ||
62 | +// with contributions from Tim Paine | ||
63 | +// with contributions from Fabio Pellacini | ||
64 | +// with contributions from Lénárd Szolnoki | ||
65 | +// with contributions from Jan Pharago | ||
66 | +// with contributions from Maya Warrier | ||
67 | +// with contributions from Taha Khokhar | ||
68 | +// | ||
69 | +// | ||
70 | +// MIT License Notice | ||
71 | +// | ||
72 | +// MIT License | ||
73 | +// | ||
74 | +// Copyright (c) 2021 The fast_float authors | ||
75 | +// | ||
76 | +// Permission is hereby granted, free of charge, to any | ||
77 | +// person obtaining a copy of this software and associated | ||
78 | +// documentation files (the "Software"), to deal in the | ||
79 | +// Software without restriction, including without | ||
80 | +// limitation the rights to use, copy, modify, merge, | ||
81 | +// publish, distribute, sublicense, and/or sell copies of | ||
82 | +// the Software, and to permit persons to whom the Software | ||
83 | +// is furnished to do so, subject to the following | ||
84 | +// conditions: | ||
85 | +// | ||
86 | +// The above copyright notice and this permission notice | ||
87 | +// shall be included in all copies or substantial portions | ||
88 | +// of the Software. | ||
89 | +// | ||
90 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
91 | +// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
92 | +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
93 | +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
94 | +// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
95 | +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
96 | +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||
97 | +// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
98 | +// DEALINGS IN THE SOFTWARE. | ||
99 | +// | ||
100 | + | ||
101 | +#ifndef FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H | ||
102 | +#define FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H | ||
103 | + | ||
104 | +#ifdef __has_include | ||
105 | +#if __has_include(<version>) | ||
106 | +#include <version> | ||
107 | +#endif | ||
108 | +#endif | ||
109 | + | ||
110 | +// Testing for https://wg21.link/N3652, adopted in C++14 | ||
111 | +#if __cpp_constexpr >= 201304 | ||
112 | +#define FASTFLOAT_CONSTEXPR14 constexpr | ||
113 | +#else | ||
114 | +#define FASTFLOAT_CONSTEXPR14 | ||
115 | +#endif | ||
116 | + | ||
117 | +#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L | ||
118 | +#define FASTFLOAT_HAS_BIT_CAST 1 | ||
119 | +#else | ||
120 | +#define FASTFLOAT_HAS_BIT_CAST 0 | ||
121 | +#endif | ||
122 | + | ||
123 | +#if defined(__cpp_lib_is_constant_evaluated) && \ | ||
124 | + __cpp_lib_is_constant_evaluated >= 201811L | ||
125 | +#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1 | ||
126 | +#else | ||
127 | +#define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0 | ||
128 | +#endif | ||
129 | + | ||
130 | +// Testing for relevant C++20 constexpr library features | ||
131 | +#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED && FASTFLOAT_HAS_BIT_CAST && \ | ||
132 | + __cpp_lib_constexpr_algorithms >= 201806L /*For std::copy and std::fill*/ | ||
133 | +#define FASTFLOAT_CONSTEXPR20 constexpr | ||
134 | +#define FASTFLOAT_IS_CONSTEXPR 1 | ||
135 | +#else | ||
136 | +#define FASTFLOAT_CONSTEXPR20 | ||
137 | +#define FASTFLOAT_IS_CONSTEXPR 0 | ||
138 | +#endif | ||
139 | + | ||
140 | +#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) | ||
141 | +#define FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE 0 | ||
142 | +#else | ||
143 | +#define FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE 1 | ||
144 | +#endif | ||
145 | + | ||
146 | +#endif // FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H | ||
147 | + | ||
148 | +#ifndef FASTFLOAT_FLOAT_COMMON_H | ||
149 | +#define FASTFLOAT_FLOAT_COMMON_H | ||
150 | + | ||
151 | +#include <cfloat> | ||
152 | +#include <cstdint> | ||
153 | +#include <cassert> | ||
154 | +#include <cstring> | ||
155 | +#include <type_traits> | ||
156 | +#include <system_error> | ||
157 | +#ifdef __has_include | ||
158 | +#if __has_include(<stdfloat>) && (__cplusplus > 202002L || _MSVC_LANG > 202002L) | ||
159 | +#include <stdfloat> | ||
160 | +#endif | ||
161 | +#endif | ||
162 | + | ||
163 | +namespace fast_float { | ||
164 | + | ||
165 | +#define FASTFLOAT_JSONFMT (1 << 5) | ||
166 | +#define FASTFLOAT_FORTRANFMT (1 << 6) | ||
167 | + | ||
168 | +enum chars_format { | ||
169 | + scientific = 1 << 0, | ||
170 | + fixed = 1 << 2, | ||
171 | + hex = 1 << 3, | ||
172 | + no_infnan = 1 << 4, | ||
173 | + // RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6 | ||
174 | + json = FASTFLOAT_JSONFMT | fixed | scientific | no_infnan, | ||
175 | + // Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed. | ||
176 | + json_or_infnan = FASTFLOAT_JSONFMT | fixed | scientific, | ||
177 | + fortran = FASTFLOAT_FORTRANFMT | fixed | scientific, | ||
178 | + general = fixed | scientific | ||
179 | +}; | ||
180 | + | ||
181 | +template <typename UC> struct from_chars_result_t { | ||
182 | + UC const *ptr; | ||
183 | + std::errc ec; | ||
184 | +}; | ||
185 | +using from_chars_result = from_chars_result_t<char>; | ||
186 | + | ||
187 | +template <typename UC> struct parse_options_t { | ||
188 | + constexpr explicit parse_options_t(chars_format fmt = chars_format::general, | ||
189 | + UC dot = UC('.')) | ||
190 | + : format(fmt), decimal_point(dot) {} | ||
191 | + | ||
192 | + /** Which number formats are accepted */ | ||
193 | + chars_format format; | ||
194 | + /** The character used as decimal point */ | ||
195 | + UC decimal_point; | ||
196 | +}; | ||
197 | +using parse_options = parse_options_t<char>; | ||
198 | + | ||
199 | +} // namespace fast_float | ||
200 | + | ||
201 | +#if FASTFLOAT_HAS_BIT_CAST | ||
202 | +#include <bit> | ||
203 | +#endif | ||
204 | + | ||
205 | +#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ | ||
206 | + defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) || \ | ||
207 | + defined(__MINGW64__) || defined(__s390x__) || \ | ||
208 | + (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || \ | ||
209 | + defined(__PPC64LE__)) || \ | ||
210 | + defined(__loongarch64)) | ||
211 | +#define FASTFLOAT_64BIT 1 | ||
212 | +#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ | ||
213 | + defined(__arm__) || defined(_M_ARM) || defined(__ppc__) || \ | ||
214 | + defined(__MINGW32__) || defined(__EMSCRIPTEN__)) | ||
215 | +#define FASTFLOAT_32BIT 1 | ||
216 | +#else | ||
217 | + // Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow. | ||
218 | +// We can never tell the register width, but the SIZE_MAX is a good | ||
219 | +// approximation. UINTPTR_MAX and INTPTR_MAX are optional, so avoid them for max | ||
220 | +// portability. | ||
221 | +#if SIZE_MAX == 0xffff | ||
222 | +#error Unknown platform (16-bit, unsupported) | ||
223 | +#elif SIZE_MAX == 0xffffffff | ||
224 | +#define FASTFLOAT_32BIT 1 | ||
225 | +#elif SIZE_MAX == 0xffffffffffffffff | ||
226 | +#define FASTFLOAT_64BIT 1 | ||
227 | +#else | ||
228 | +#error Unknown platform (not 32-bit, not 64-bit?) | ||
229 | +#endif | ||
230 | +#endif | ||
231 | + | ||
232 | +#if ((defined(_WIN32) || defined(_WIN64)) && !defined(__clang__)) || \ | ||
233 | + (defined(_M_ARM64) && !defined(__MINGW32__)) | ||
234 | +#include <intrin.h> | ||
235 | +#endif | ||
236 | + | ||
237 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
238 | +#define FASTFLOAT_VISUAL_STUDIO 1 | ||
239 | +#endif | ||
240 | + | ||
241 | +#if defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__ | ||
242 | +#define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) | ||
243 | +#elif defined _WIN32 | ||
244 | +#define FASTFLOAT_IS_BIG_ENDIAN 0 | ||
245 | +#else | ||
246 | +#if defined(__APPLE__) || defined(__FreeBSD__) | ||
247 | +#include <machine/endian.h> | ||
248 | +#elif defined(sun) || defined(__sun) | ||
249 | +#include <sys/byteorder.h> | ||
250 | +#elif defined(__MVS__) | ||
251 | +#include <sys/endian.h> | ||
252 | +#else | ||
253 | +#ifdef __has_include | ||
254 | +#if __has_include(<endian.h>) | ||
255 | +#include <endian.h> | ||
256 | +#endif //__has_include(<endian.h>) | ||
257 | +#endif //__has_include | ||
258 | +#endif | ||
259 | +# | ||
260 | +#ifndef __BYTE_ORDER__ | ||
261 | +// safe choice | ||
262 | +#define FASTFLOAT_IS_BIG_ENDIAN 0 | ||
263 | +#endif | ||
264 | +# | ||
265 | +#ifndef __ORDER_LITTLE_ENDIAN__ | ||
266 | +// safe choice | ||
267 | +#define FASTFLOAT_IS_BIG_ENDIAN 0 | ||
268 | +#endif | ||
269 | +# | ||
270 | +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
271 | +#define FASTFLOAT_IS_BIG_ENDIAN 0 | ||
272 | +#else | ||
273 | +#define FASTFLOAT_IS_BIG_ENDIAN 1 | ||
274 | +#endif | ||
275 | +#endif | ||
276 | + | ||
277 | +#if defined(__SSE2__) || (defined(FASTFLOAT_VISUAL_STUDIO) && \ | ||
278 | + (defined(_M_AMD64) || defined(_M_X64) || \ | ||
279 | + (defined(_M_IX86_FP) && _M_IX86_FP == 2))) | ||
280 | +#define FASTFLOAT_SSE2 1 | ||
281 | +#endif | ||
282 | + | ||
283 | +#if defined(__aarch64__) || defined(_M_ARM64) | ||
284 | +#define FASTFLOAT_NEON 1 | ||
285 | +#endif | ||
286 | + | ||
287 | +#if defined(FASTFLOAT_SSE2) || defined(FASTFLOAT_NEON) | ||
288 | +#define FASTFLOAT_HAS_SIMD 1 | ||
289 | +#endif | ||
290 | + | ||
291 | +#if defined(__GNUC__) | ||
292 | +// disable -Wcast-align=strict (GCC only) | ||
293 | +#define FASTFLOAT_SIMD_DISABLE_WARNINGS \ | ||
294 | + _Pragma("GCC diagnostic push") \ | ||
295 | + _Pragma("GCC diagnostic ignored \"-Wcast-align\"") | ||
296 | +#else | ||
297 | +#define FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
298 | +#endif | ||
299 | + | ||
300 | +#if defined(__GNUC__) | ||
301 | +#define FASTFLOAT_SIMD_RESTORE_WARNINGS _Pragma("GCC diagnostic pop") | ||
302 | +#else | ||
303 | +#define FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
304 | +#endif | ||
305 | + | ||
306 | +#ifdef FASTFLOAT_VISUAL_STUDIO | ||
307 | +#define fastfloat_really_inline __forceinline | ||
308 | +#else | ||
309 | +#define fastfloat_really_inline inline __attribute__((always_inline)) | ||
310 | +#endif | ||
311 | + | ||
312 | +#ifndef FASTFLOAT_ASSERT | ||
313 | +#define FASTFLOAT_ASSERT(x) \ | ||
314 | + { ((void)(x)); } | ||
315 | +#endif | ||
316 | + | ||
317 | +#ifndef FASTFLOAT_DEBUG_ASSERT | ||
318 | +#define FASTFLOAT_DEBUG_ASSERT(x) \ | ||
319 | + { ((void)(x)); } | ||
320 | +#endif | ||
321 | + | ||
322 | +// rust style `try!()` macro, or `?` operator | ||
323 | +#define FASTFLOAT_TRY(x) \ | ||
324 | + { \ | ||
325 | + if (!(x)) \ | ||
326 | + return false; \ | ||
327 | + } | ||
328 | + | ||
329 | +#define FASTFLOAT_ENABLE_IF(...) \ | ||
330 | + typename std::enable_if<(__VA_ARGS__), int>::type | ||
331 | + | ||
332 | +namespace fast_float { | ||
333 | + | ||
334 | +fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() { | ||
335 | +#if FASTFLOAT_HAS_IS_CONSTANT_EVALUATED | ||
336 | + return std::is_constant_evaluated(); | ||
337 | +#else | ||
338 | + return false; | ||
339 | +#endif | ||
340 | +} | ||
341 | + | ||
342 | +template <typename T> | ||
343 | +fastfloat_really_inline constexpr bool is_supported_float_type() { | ||
344 | + return std::is_same<T, float>::value || std::is_same<T, double>::value | ||
345 | +#if __STDCPP_FLOAT32_T__ | ||
346 | + || std::is_same<T, std::float32_t>::value | ||
347 | +#endif | ||
348 | +#if __STDCPP_FLOAT64_T__ | ||
349 | + || std::is_same<T, std::float64_t>::value | ||
350 | +#endif | ||
351 | + ; | ||
352 | +} | ||
353 | + | ||
354 | +template <typename UC> | ||
355 | +fastfloat_really_inline constexpr bool is_supported_char_type() { | ||
356 | + return std::is_same<UC, char>::value || std::is_same<UC, wchar_t>::value || | ||
357 | + std::is_same<UC, char16_t>::value || std::is_same<UC, char32_t>::value; | ||
358 | +} | ||
359 | + | ||
360 | +// Compares two ASCII strings in a case insensitive manner. | ||
361 | +template <typename UC> | ||
362 | +inline FASTFLOAT_CONSTEXPR14 bool | ||
363 | +fastfloat_strncasecmp(UC const *input1, UC const *input2, size_t length) { | ||
364 | + char running_diff{0}; | ||
365 | + for (size_t i = 0; i < length; ++i) { | ||
366 | + running_diff |= (char(input1[i]) ^ char(input2[i])); | ||
367 | + } | ||
368 | + return (running_diff == 0) || (running_diff == 32); | ||
369 | +} | ||
370 | + | ||
371 | +#ifndef FLT_EVAL_METHOD | ||
372 | +#error "FLT_EVAL_METHOD should be defined, please include cfloat." | ||
373 | +#endif | ||
374 | + | ||
375 | +// a pointer and a length to a contiguous block of memory | ||
376 | +template <typename T> struct span { | ||
377 | + const T *ptr; | ||
378 | + size_t length; | ||
379 | + constexpr span(const T *_ptr, size_t _length) : ptr(_ptr), length(_length) {} | ||
380 | + constexpr span() : ptr(nullptr), length(0) {} | ||
381 | + | ||
382 | + constexpr size_t len() const noexcept { return length; } | ||
383 | + | ||
384 | + FASTFLOAT_CONSTEXPR14 const T &operator[](size_t index) const noexcept { | ||
385 | + FASTFLOAT_DEBUG_ASSERT(index < length); | ||
386 | + return ptr[index]; | ||
387 | + } | ||
388 | +}; | ||
389 | + | ||
390 | +struct value128 { | ||
391 | + uint64_t low; | ||
392 | + uint64_t high; | ||
393 | + constexpr value128(uint64_t _low, uint64_t _high) : low(_low), high(_high) {} | ||
394 | + constexpr value128() : low(0), high(0) {} | ||
395 | +}; | ||
396 | + | ||
397 | +/* Helper C++14 constexpr generic implementation of leading_zeroes */ | ||
398 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int | ||
399 | +leading_zeroes_generic(uint64_t input_num, int last_bit = 0) { | ||
400 | + if (input_num & uint64_t(0xffffffff00000000)) { | ||
401 | + input_num >>= 32; | ||
402 | + last_bit |= 32; | ||
403 | + } | ||
404 | + if (input_num & uint64_t(0xffff0000)) { | ||
405 | + input_num >>= 16; | ||
406 | + last_bit |= 16; | ||
407 | + } | ||
408 | + if (input_num & uint64_t(0xff00)) { | ||
409 | + input_num >>= 8; | ||
410 | + last_bit |= 8; | ||
411 | + } | ||
412 | + if (input_num & uint64_t(0xf0)) { | ||
413 | + input_num >>= 4; | ||
414 | + last_bit |= 4; | ||
415 | + } | ||
416 | + if (input_num & uint64_t(0xc)) { | ||
417 | + input_num >>= 2; | ||
418 | + last_bit |= 2; | ||
419 | + } | ||
420 | + if (input_num & uint64_t(0x2)) { /* input_num >>= 1; */ | ||
421 | + last_bit |= 1; | ||
422 | + } | ||
423 | + return 63 - last_bit; | ||
424 | +} | ||
425 | + | ||
426 | +/* result might be undefined when input_num is zero */ | ||
427 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 int | ||
428 | +leading_zeroes(uint64_t input_num) { | ||
429 | + assert(input_num > 0); | ||
430 | + if (cpp20_and_in_constexpr()) { | ||
431 | + return leading_zeroes_generic(input_num); | ||
432 | + } | ||
433 | +#ifdef FASTFLOAT_VISUAL_STUDIO | ||
434 | +#if defined(_M_X64) || defined(_M_ARM64) | ||
435 | + unsigned long leading_zero = 0; | ||
436 | + // Search the mask data from most significant bit (MSB) | ||
437 | + // to least significant bit (LSB) for a set bit (1). | ||
438 | + _BitScanReverse64(&leading_zero, input_num); | ||
439 | + return (int)(63 - leading_zero); | ||
440 | +#else | ||
441 | + return leading_zeroes_generic(input_num); | ||
442 | +#endif | ||
443 | +#else | ||
444 | + return __builtin_clzll(input_num); | ||
445 | +#endif | ||
446 | +} | ||
447 | + | ||
448 | +// slow emulation routine for 32-bit | ||
449 | +fastfloat_really_inline constexpr uint64_t emulu(uint32_t x, uint32_t y) { | ||
450 | + return x * (uint64_t)y; | ||
451 | +} | ||
452 | + | ||
453 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t | ||
454 | +umul128_generic(uint64_t ab, uint64_t cd, uint64_t *hi) { | ||
455 | + uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd); | ||
456 | + uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd); | ||
457 | + uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32)); | ||
458 | + uint64_t adbc_carry = (uint64_t)(adbc < ad); | ||
459 | + uint64_t lo = bd + (adbc << 32); | ||
460 | + *hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) + | ||
461 | + (adbc_carry << 32) + (uint64_t)(lo < bd); | ||
462 | + return lo; | ||
463 | +} | ||
464 | + | ||
465 | +#ifdef FASTFLOAT_32BIT | ||
466 | + | ||
467 | +// slow emulation routine for 32-bit | ||
468 | +#if !defined(__MINGW64__) | ||
469 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t _umul128(uint64_t ab, | ||
470 | + uint64_t cd, | ||
471 | + uint64_t *hi) { | ||
472 | + return umul128_generic(ab, cd, hi); | ||
473 | +} | ||
474 | +#endif // !__MINGW64__ | ||
475 | + | ||
476 | +#endif // FASTFLOAT_32BIT | ||
477 | + | ||
478 | +// compute 64-bit a*b | ||
479 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128 | ||
480 | +full_multiplication(uint64_t a, uint64_t b) { | ||
481 | + if (cpp20_and_in_constexpr()) { | ||
482 | + value128 answer; | ||
483 | + answer.low = umul128_generic(a, b, &answer.high); | ||
484 | + return answer; | ||
485 | + } | ||
486 | + value128 answer; | ||
487 | +#if defined(_M_ARM64) && !defined(__MINGW32__) | ||
488 | + // ARM64 has native support for 64-bit multiplications, no need to emulate | ||
489 | + // But MinGW on ARM64 doesn't have native support for 64-bit multiplications | ||
490 | + answer.high = __umulh(a, b); | ||
491 | + answer.low = a * b; | ||
492 | +#elif defined(FASTFLOAT_32BIT) || \ | ||
493 | + (defined(_WIN64) && !defined(__clang__) && !defined(_M_ARM64)) | ||
494 | + answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64 | ||
495 | +#elif defined(FASTFLOAT_64BIT) && defined(__SIZEOF_INT128__) | ||
496 | + __uint128_t r = ((__uint128_t)a) * b; | ||
497 | + answer.low = uint64_t(r); | ||
498 | + answer.high = uint64_t(r >> 64); | ||
499 | +#else | ||
500 | + answer.low = umul128_generic(a, b, &answer.high); | ||
501 | +#endif | ||
502 | + return answer; | ||
503 | +} | ||
504 | + | ||
505 | +struct adjusted_mantissa { | ||
506 | + uint64_t mantissa{0}; | ||
507 | + int32_t power2{0}; // a negative value indicates an invalid result | ||
508 | + adjusted_mantissa() = default; | ||
509 | + constexpr bool operator==(const adjusted_mantissa &o) const { | ||
510 | + return mantissa == o.mantissa && power2 == o.power2; | ||
511 | + } | ||
512 | + constexpr bool operator!=(const adjusted_mantissa &o) const { | ||
513 | + return mantissa != o.mantissa || power2 != o.power2; | ||
514 | + } | ||
515 | +}; | ||
516 | + | ||
517 | +// Bias so we can get the real exponent with an invalid adjusted_mantissa. | ||
518 | +constexpr static int32_t invalid_am_bias = -0x8000; | ||
519 | + | ||
520 | +// used for binary_format_lookup_tables<T>::max_mantissa | ||
521 | +constexpr uint64_t constant_55555 = 5 * 5 * 5 * 5 * 5; | ||
522 | + | ||
523 | +template <typename T, typename U = void> struct binary_format_lookup_tables; | ||
524 | + | ||
525 | +template <typename T> struct binary_format : binary_format_lookup_tables<T> { | ||
526 | + using equiv_uint = | ||
527 | + typename std::conditional<sizeof(T) == 4, uint32_t, uint64_t>::type; | ||
528 | + | ||
529 | + static inline constexpr int mantissa_explicit_bits(); | ||
530 | + static inline constexpr int minimum_exponent(); | ||
531 | + static inline constexpr int infinite_power(); | ||
532 | + static inline constexpr int sign_index(); | ||
533 | + static inline constexpr int | ||
534 | + min_exponent_fast_path(); // used when fegetround() == FE_TONEAREST | ||
535 | + static inline constexpr int max_exponent_fast_path(); | ||
536 | + static inline constexpr int max_exponent_round_to_even(); | ||
537 | + static inline constexpr int min_exponent_round_to_even(); | ||
538 | + static inline constexpr uint64_t max_mantissa_fast_path(int64_t power); | ||
539 | + static inline constexpr uint64_t | ||
540 | + max_mantissa_fast_path(); // used when fegetround() == FE_TONEAREST | ||
541 | + static inline constexpr int largest_power_of_ten(); | ||
542 | + static inline constexpr int smallest_power_of_ten(); | ||
543 | + static inline constexpr T exact_power_of_ten(int64_t power); | ||
544 | + static inline constexpr size_t max_digits(); | ||
545 | + static inline constexpr equiv_uint exponent_mask(); | ||
546 | + static inline constexpr equiv_uint mantissa_mask(); | ||
547 | + static inline constexpr equiv_uint hidden_bit_mask(); | ||
548 | +}; | ||
549 | + | ||
550 | +template <typename U> struct binary_format_lookup_tables<double, U> { | ||
551 | + static constexpr double powers_of_ten[] = { | ||
552 | + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, | ||
553 | + 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; | ||
554 | + | ||
555 | + // Largest integer value v so that (5**index * v) <= 1<<53. | ||
556 | + // 0x20000000000000 == 1 << 53 | ||
557 | + static constexpr uint64_t max_mantissa[] = { | ||
558 | + 0x20000000000000, | ||
559 | + 0x20000000000000 / 5, | ||
560 | + 0x20000000000000 / (5 * 5), | ||
561 | + 0x20000000000000 / (5 * 5 * 5), | ||
562 | + 0x20000000000000 / (5 * 5 * 5 * 5), | ||
563 | + 0x20000000000000 / (constant_55555), | ||
564 | + 0x20000000000000 / (constant_55555 * 5), | ||
565 | + 0x20000000000000 / (constant_55555 * 5 * 5), | ||
566 | + 0x20000000000000 / (constant_55555 * 5 * 5 * 5), | ||
567 | + 0x20000000000000 / (constant_55555 * 5 * 5 * 5 * 5), | ||
568 | + 0x20000000000000 / (constant_55555 * constant_55555), | ||
569 | + 0x20000000000000 / (constant_55555 * constant_55555 * 5), | ||
570 | + 0x20000000000000 / (constant_55555 * constant_55555 * 5 * 5), | ||
571 | + 0x20000000000000 / (constant_55555 * constant_55555 * 5 * 5 * 5), | ||
572 | + 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555), | ||
573 | + 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 * 5), | ||
574 | + 0x20000000000000 / | ||
575 | + (constant_55555 * constant_55555 * constant_55555 * 5 * 5), | ||
576 | + 0x20000000000000 / | ||
577 | + (constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5), | ||
578 | + 0x20000000000000 / | ||
579 | + (constant_55555 * constant_55555 * constant_55555 * 5 * 5 * 5 * 5), | ||
580 | + 0x20000000000000 / | ||
581 | + (constant_55555 * constant_55555 * constant_55555 * constant_55555), | ||
582 | + 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 * | ||
583 | + constant_55555 * 5), | ||
584 | + 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 * | ||
585 | + constant_55555 * 5 * 5), | ||
586 | + 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 * | ||
587 | + constant_55555 * 5 * 5 * 5), | ||
588 | + 0x20000000000000 / (constant_55555 * constant_55555 * constant_55555 * | ||
589 | + constant_55555 * 5 * 5 * 5 * 5)}; | ||
590 | +}; | ||
591 | + | ||
592 | +#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE | ||
593 | + | ||
594 | +template <typename U> | ||
595 | +constexpr double binary_format_lookup_tables<double, U>::powers_of_ten[]; | ||
596 | + | ||
597 | +template <typename U> | ||
598 | +constexpr uint64_t binary_format_lookup_tables<double, U>::max_mantissa[]; | ||
599 | + | ||
600 | +#endif | ||
601 | + | ||
602 | +template <typename U> struct binary_format_lookup_tables<float, U> { | ||
603 | + static constexpr float powers_of_ten[] = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f, | ||
604 | + 1e6f, 1e7f, 1e8f, 1e9f, 1e10f}; | ||
605 | + | ||
606 | + // Largest integer value v so that (5**index * v) <= 1<<24. | ||
607 | + // 0x1000000 == 1<<24 | ||
608 | + static constexpr uint64_t max_mantissa[] = { | ||
609 | + 0x1000000, | ||
610 | + 0x1000000 / 5, | ||
611 | + 0x1000000 / (5 * 5), | ||
612 | + 0x1000000 / (5 * 5 * 5), | ||
613 | + 0x1000000 / (5 * 5 * 5 * 5), | ||
614 | + 0x1000000 / (constant_55555), | ||
615 | + 0x1000000 / (constant_55555 * 5), | ||
616 | + 0x1000000 / (constant_55555 * 5 * 5), | ||
617 | + 0x1000000 / (constant_55555 * 5 * 5 * 5), | ||
618 | + 0x1000000 / (constant_55555 * 5 * 5 * 5 * 5), | ||
619 | + 0x1000000 / (constant_55555 * constant_55555), | ||
620 | + 0x1000000 / (constant_55555 * constant_55555 * 5)}; | ||
621 | +}; | ||
622 | + | ||
623 | +#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE | ||
624 | + | ||
625 | +template <typename U> | ||
626 | +constexpr float binary_format_lookup_tables<float, U>::powers_of_ten[]; | ||
627 | + | ||
628 | +template <typename U> | ||
629 | +constexpr uint64_t binary_format_lookup_tables<float, U>::max_mantissa[]; | ||
630 | + | ||
631 | +#endif | ||
632 | + | ||
633 | +template <> | ||
634 | +inline constexpr int binary_format<double>::min_exponent_fast_path() { | ||
635 | +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) | ||
636 | + return 0; | ||
637 | +#else | ||
638 | + return -22; | ||
639 | +#endif | ||
640 | +} | ||
641 | + | ||
642 | +template <> | ||
643 | +inline constexpr int binary_format<float>::min_exponent_fast_path() { | ||
644 | +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) | ||
645 | + return 0; | ||
646 | +#else | ||
647 | + return -10; | ||
648 | +#endif | ||
649 | +} | ||
650 | + | ||
651 | +template <> | ||
652 | +inline constexpr int binary_format<double>::mantissa_explicit_bits() { | ||
653 | + return 52; | ||
654 | +} | ||
655 | +template <> | ||
656 | +inline constexpr int binary_format<float>::mantissa_explicit_bits() { | ||
657 | + return 23; | ||
658 | +} | ||
659 | + | ||
660 | +template <> | ||
661 | +inline constexpr int binary_format<double>::max_exponent_round_to_even() { | ||
662 | + return 23; | ||
663 | +} | ||
664 | + | ||
665 | +template <> | ||
666 | +inline constexpr int binary_format<float>::max_exponent_round_to_even() { | ||
667 | + return 10; | ||
668 | +} | ||
669 | + | ||
670 | +template <> | ||
671 | +inline constexpr int binary_format<double>::min_exponent_round_to_even() { | ||
672 | + return -4; | ||
673 | +} | ||
674 | + | ||
675 | +template <> | ||
676 | +inline constexpr int binary_format<float>::min_exponent_round_to_even() { | ||
677 | + return -17; | ||
678 | +} | ||
679 | + | ||
680 | +template <> inline constexpr int binary_format<double>::minimum_exponent() { | ||
681 | + return -1023; | ||
682 | +} | ||
683 | +template <> inline constexpr int binary_format<float>::minimum_exponent() { | ||
684 | + return -127; | ||
685 | +} | ||
686 | + | ||
687 | +template <> inline constexpr int binary_format<double>::infinite_power() { | ||
688 | + return 0x7FF; | ||
689 | +} | ||
690 | +template <> inline constexpr int binary_format<float>::infinite_power() { | ||
691 | + return 0xFF; | ||
692 | +} | ||
693 | + | ||
694 | +template <> inline constexpr int binary_format<double>::sign_index() { | ||
695 | + return 63; | ||
696 | +} | ||
697 | +template <> inline constexpr int binary_format<float>::sign_index() { | ||
698 | + return 31; | ||
699 | +} | ||
700 | + | ||
701 | +template <> | ||
702 | +inline constexpr int binary_format<double>::max_exponent_fast_path() { | ||
703 | + return 22; | ||
704 | +} | ||
705 | +template <> | ||
706 | +inline constexpr int binary_format<float>::max_exponent_fast_path() { | ||
707 | + return 10; | ||
708 | +} | ||
709 | + | ||
710 | +template <> | ||
711 | +inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() { | ||
712 | + return uint64_t(2) << mantissa_explicit_bits(); | ||
713 | +} | ||
714 | +template <> | ||
715 | +inline constexpr uint64_t | ||
716 | +binary_format<double>::max_mantissa_fast_path(int64_t power) { | ||
717 | + // caller is responsible to ensure that | ||
718 | + // power >= 0 && power <= 22 | ||
719 | + // | ||
720 | + // Work around clang bug https://godbolt.org/z/zedh7rrhc | ||
721 | + return (void)max_mantissa[0], max_mantissa[power]; | ||
722 | +} | ||
723 | +template <> | ||
724 | +inline constexpr uint64_t binary_format<float>::max_mantissa_fast_path() { | ||
725 | + return uint64_t(2) << mantissa_explicit_bits(); | ||
726 | +} | ||
727 | +template <> | ||
728 | +inline constexpr uint64_t | ||
729 | +binary_format<float>::max_mantissa_fast_path(int64_t power) { | ||
730 | + // caller is responsible to ensure that | ||
731 | + // power >= 0 && power <= 10 | ||
732 | + // | ||
733 | + // Work around clang bug https://godbolt.org/z/zedh7rrhc | ||
734 | + return (void)max_mantissa[0], max_mantissa[power]; | ||
735 | +} | ||
736 | + | ||
737 | +template <> | ||
738 | +inline constexpr double | ||
739 | +binary_format<double>::exact_power_of_ten(int64_t power) { | ||
740 | + // Work around clang bug https://godbolt.org/z/zedh7rrhc | ||
741 | + return (void)powers_of_ten[0], powers_of_ten[power]; | ||
742 | +} | ||
743 | +template <> | ||
744 | +inline constexpr float binary_format<float>::exact_power_of_ten(int64_t power) { | ||
745 | + // Work around clang bug https://godbolt.org/z/zedh7rrhc | ||
746 | + return (void)powers_of_ten[0], powers_of_ten[power]; | ||
747 | +} | ||
748 | + | ||
749 | +template <> inline constexpr int binary_format<double>::largest_power_of_ten() { | ||
750 | + return 308; | ||
751 | +} | ||
752 | +template <> inline constexpr int binary_format<float>::largest_power_of_ten() { | ||
753 | + return 38; | ||
754 | +} | ||
755 | + | ||
756 | +template <> | ||
757 | +inline constexpr int binary_format<double>::smallest_power_of_ten() { | ||
758 | + return -342; | ||
759 | +} | ||
760 | +template <> inline constexpr int binary_format<float>::smallest_power_of_ten() { | ||
761 | + return -64; | ||
762 | +} | ||
763 | + | ||
764 | +template <> inline constexpr size_t binary_format<double>::max_digits() { | ||
765 | + return 769; | ||
766 | +} | ||
767 | +template <> inline constexpr size_t binary_format<float>::max_digits() { | ||
768 | + return 114; | ||
769 | +} | ||
770 | + | ||
771 | +template <> | ||
772 | +inline constexpr binary_format<float>::equiv_uint | ||
773 | +binary_format<float>::exponent_mask() { | ||
774 | + return 0x7F800000; | ||
775 | +} | ||
776 | +template <> | ||
777 | +inline constexpr binary_format<double>::equiv_uint | ||
778 | +binary_format<double>::exponent_mask() { | ||
779 | + return 0x7FF0000000000000; | ||
780 | +} | ||
781 | + | ||
782 | +template <> | ||
783 | +inline constexpr binary_format<float>::equiv_uint | ||
784 | +binary_format<float>::mantissa_mask() { | ||
785 | + return 0x007FFFFF; | ||
786 | +} | ||
787 | +template <> | ||
788 | +inline constexpr binary_format<double>::equiv_uint | ||
789 | +binary_format<double>::mantissa_mask() { | ||
790 | + return 0x000FFFFFFFFFFFFF; | ||
791 | +} | ||
792 | + | ||
793 | +template <> | ||
794 | +inline constexpr binary_format<float>::equiv_uint | ||
795 | +binary_format<float>::hidden_bit_mask() { | ||
796 | + return 0x00800000; | ||
797 | +} | ||
798 | +template <> | ||
799 | +inline constexpr binary_format<double>::equiv_uint | ||
800 | +binary_format<double>::hidden_bit_mask() { | ||
801 | + return 0x0010000000000000; | ||
802 | +} | ||
803 | + | ||
804 | +template <typename T> | ||
805 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
806 | +to_float(bool negative, adjusted_mantissa am, T &value) { | ||
807 | + using fastfloat_uint = typename binary_format<T>::equiv_uint; | ||
808 | + fastfloat_uint word = (fastfloat_uint)am.mantissa; | ||
809 | + word |= fastfloat_uint(am.power2) | ||
810 | + << binary_format<T>::mantissa_explicit_bits(); | ||
811 | + word |= fastfloat_uint(negative) << binary_format<T>::sign_index(); | ||
812 | +#if FASTFLOAT_HAS_BIT_CAST | ||
813 | + value = std::bit_cast<T>(word); | ||
814 | +#else | ||
815 | + ::memcpy(&value, &word, sizeof(T)); | ||
816 | +#endif | ||
817 | +} | ||
818 | + | ||
819 | +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default | ||
820 | +template <typename = void> struct space_lut { | ||
821 | + static constexpr bool value[] = { | ||
822 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
823 | + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
824 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
825 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
826 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
827 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
828 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
829 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
830 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
831 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
832 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
833 | +}; | ||
834 | + | ||
835 | +#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE | ||
836 | + | ||
837 | +template <typename T> constexpr bool space_lut<T>::value[]; | ||
838 | + | ||
839 | +#endif | ||
840 | + | ||
841 | +inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; } | ||
842 | +#endif | ||
843 | + | ||
844 | +template <typename UC> static constexpr uint64_t int_cmp_zeros() { | ||
845 | + static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4), | ||
846 | + "Unsupported character size"); | ||
847 | + return (sizeof(UC) == 1) ? 0x3030303030303030 | ||
848 | + : (sizeof(UC) == 2) | ||
849 | + ? (uint64_t(UC('0')) << 48 | uint64_t(UC('0')) << 32 | | ||
850 | + uint64_t(UC('0')) << 16 | UC('0')) | ||
851 | + : (uint64_t(UC('0')) << 32 | UC('0')); | ||
852 | +} | ||
853 | +template <typename UC> static constexpr int int_cmp_len() { | ||
854 | + return sizeof(uint64_t) / sizeof(UC); | ||
855 | +} | ||
856 | +template <typename UC> static constexpr UC const *str_const_nan() { | ||
857 | + return nullptr; | ||
858 | +} | ||
859 | +template <> constexpr char const *str_const_nan<char>() { return "nan"; } | ||
860 | +template <> constexpr wchar_t const *str_const_nan<wchar_t>() { return L"nan"; } | ||
861 | +template <> constexpr char16_t const *str_const_nan<char16_t>() { | ||
862 | + return u"nan"; | ||
863 | +} | ||
864 | +template <> constexpr char32_t const *str_const_nan<char32_t>() { | ||
865 | + return U"nan"; | ||
866 | +} | ||
867 | +template <typename UC> static constexpr UC const *str_const_inf() { | ||
868 | + return nullptr; | ||
869 | +} | ||
870 | +template <> constexpr char const *str_const_inf<char>() { return "infinity"; } | ||
871 | +template <> constexpr wchar_t const *str_const_inf<wchar_t>() { | ||
872 | + return L"infinity"; | ||
873 | +} | ||
874 | +template <> constexpr char16_t const *str_const_inf<char16_t>() { | ||
875 | + return u"infinity"; | ||
876 | +} | ||
877 | +template <> constexpr char32_t const *str_const_inf<char32_t>() { | ||
878 | + return U"infinity"; | ||
879 | +} | ||
880 | + | ||
881 | +template <typename = void> struct int_luts { | ||
882 | + static constexpr uint8_t chdigit[] = { | ||
883 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
884 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
885 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
886 | + 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, | ||
887 | + 255, 255, 255, 255, 255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ||
888 | + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | ||
889 | + 35, 255, 255, 255, 255, 255, 255, 10, 11, 12, 13, 14, 15, 16, 17, | ||
890 | + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, | ||
891 | + 33, 34, 35, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
892 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
893 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
894 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
895 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
896 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
897 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
898 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
899 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
900 | + 255}; | ||
901 | + | ||
902 | + static constexpr size_t maxdigits_u64[] = { | ||
903 | + 64, 41, 32, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 16, 16, 16, 16, | ||
904 | + 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13}; | ||
905 | + | ||
906 | + static constexpr uint64_t min_safe_u64[] = { | ||
907 | + 9223372036854775808ull, 12157665459056928801ull, 4611686018427387904, | ||
908 | + 7450580596923828125, 4738381338321616896, 3909821048582988049, | ||
909 | + 9223372036854775808ull, 12157665459056928801ull, 10000000000000000000ull, | ||
910 | + 5559917313492231481, 2218611106740436992, 8650415919381337933, | ||
911 | + 2177953337809371136, 6568408355712890625, 1152921504606846976, | ||
912 | + 2862423051509815793, 6746640616477458432, 15181127029874798299ull, | ||
913 | + 1638400000000000000, 3243919932521508681, 6221821273427820544, | ||
914 | + 11592836324538749809ull, 876488338465357824, 1490116119384765625, | ||
915 | + 2481152873203736576, 4052555153018976267, 6502111422497947648, | ||
916 | + 10260628712958602189ull, 15943230000000000000ull, 787662783788549761, | ||
917 | + 1152921504606846976, 1667889514952984961, 2386420683693101056, | ||
918 | + 3379220508056640625, 4738381338321616896}; | ||
919 | +}; | ||
920 | + | ||
921 | +#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE | ||
922 | + | ||
923 | +template <typename T> constexpr uint8_t int_luts<T>::chdigit[]; | ||
924 | + | ||
925 | +template <typename T> constexpr size_t int_luts<T>::maxdigits_u64[]; | ||
926 | + | ||
927 | +template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[]; | ||
928 | + | ||
929 | +#endif | ||
930 | + | ||
931 | +template <typename UC> | ||
932 | +fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) { | ||
933 | + return int_luts<>::chdigit[static_cast<unsigned char>(c)]; | ||
934 | +} | ||
935 | + | ||
936 | +fastfloat_really_inline constexpr size_t max_digits_u64(int base) { | ||
937 | + return int_luts<>::maxdigits_u64[base - 2]; | ||
938 | +} | ||
939 | + | ||
940 | +// If a u64 is exactly max_digits_u64() in length, this is | ||
941 | +// the value below which it has definitely overflowed. | ||
942 | +fastfloat_really_inline constexpr uint64_t min_safe_u64(int base) { | ||
943 | + return int_luts<>::min_safe_u64[base - 2]; | ||
944 | +} | ||
945 | + | ||
946 | +} // namespace fast_float | ||
947 | + | ||
948 | +#endif | ||
949 | + | ||
950 | + | ||
951 | +#ifndef FASTFLOAT_FAST_FLOAT_H | ||
952 | +#define FASTFLOAT_FAST_FLOAT_H | ||
953 | + | ||
954 | + | ||
955 | +namespace fast_float { | ||
956 | +/** | ||
957 | + * This function parses the character sequence [first,last) for a number. It | ||
958 | + * parses floating-point numbers expecting a locale-indepent format equivalent | ||
959 | + * to what is used by std::strtod in the default ("C") locale. The resulting | ||
960 | + * floating-point value is the closest floating-point values (using either float | ||
961 | + * or double), using the "round to even" convention for values that would | ||
962 | + * otherwise fall right in-between two values. That is, we provide exact parsing | ||
963 | + * according to the IEEE standard. | ||
964 | + * | ||
965 | + * Given a successful parse, the pointer (`ptr`) in the returned value is set to | ||
966 | + * point right after the parsed number, and the `value` referenced is set to the | ||
967 | + * parsed value. In case of error, the returned `ec` contains a representative | ||
968 | + * error, otherwise the default (`std::errc()`) value is stored. | ||
969 | + * | ||
970 | + * The implementation does not throw and does not allocate memory (e.g., with | ||
971 | + * `new` or `malloc`). | ||
972 | + * | ||
973 | + * Like the C++17 standard, the `fast_float::from_chars` functions take an | ||
974 | + * optional last argument of the type `fast_float::chars_format`. It is a bitset | ||
975 | + * value: we check whether `fmt & fast_float::chars_format::fixed` and `fmt & | ||
976 | + * fast_float::chars_format::scientific` are set to determine whether we allow | ||
977 | + * the fixed point and scientific notation respectively. The default is | ||
978 | + * `fast_float::chars_format::general` which allows both `fixed` and | ||
979 | + * `scientific`. | ||
980 | + */ | ||
981 | +template <typename T, typename UC = char, | ||
982 | + typename = FASTFLOAT_ENABLE_IF(is_supported_float_type<T>())> | ||
983 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
984 | +from_chars(UC const *first, UC const *last, T &value, | ||
985 | + chars_format fmt = chars_format::general) noexcept; | ||
986 | + | ||
987 | +/** | ||
988 | + * Like from_chars, but accepts an `options` argument to govern number parsing. | ||
989 | + */ | ||
990 | +template <typename T, typename UC = char> | ||
991 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
992 | +from_chars_advanced(UC const *first, UC const *last, T &value, | ||
993 | + parse_options_t<UC> options) noexcept; | ||
994 | +/** | ||
995 | + * from_chars for integer types. | ||
996 | + */ | ||
997 | +template <typename T, typename UC = char, | ||
998 | + typename = FASTFLOAT_ENABLE_IF(!is_supported_float_type<T>())> | ||
999 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
1000 | +from_chars(UC const *first, UC const *last, T &value, int base = 10) noexcept; | ||
1001 | + | ||
1002 | +} // namespace fast_float | ||
1003 | +#endif // FASTFLOAT_FAST_FLOAT_H | ||
1004 | + | ||
1005 | +#ifndef FASTFLOAT_ASCII_NUMBER_H | ||
1006 | +#define FASTFLOAT_ASCII_NUMBER_H | ||
1007 | + | ||
1008 | +#include <cctype> | ||
1009 | +#include <cstdint> | ||
1010 | +#include <cstring> | ||
1011 | +#include <iterator> | ||
1012 | +#include <limits> | ||
1013 | +#include <type_traits> | ||
1014 | + | ||
1015 | + | ||
1016 | +#ifdef FASTFLOAT_SSE2 | ||
1017 | +#include <emmintrin.h> | ||
1018 | +#endif | ||
1019 | + | ||
1020 | +#ifdef FASTFLOAT_NEON | ||
1021 | +#include <arm_neon.h> | ||
1022 | +#endif | ||
1023 | + | ||
1024 | +namespace fast_float { | ||
1025 | + | ||
1026 | +template <typename UC> fastfloat_really_inline constexpr bool has_simd_opt() { | ||
1027 | +#ifdef FASTFLOAT_HAS_SIMD | ||
1028 | + return std::is_same<UC, char16_t>::value; | ||
1029 | +#else | ||
1030 | + return false; | ||
1031 | +#endif | ||
1032 | +} | ||
1033 | + | ||
1034 | +// Next function can be micro-optimized, but compilers are entirely | ||
1035 | +// able to optimize it well. | ||
1036 | +template <typename UC> | ||
1037 | +fastfloat_really_inline constexpr bool is_integer(UC c) noexcept { | ||
1038 | + return !(c > UC('9') || c < UC('0')); | ||
1039 | +} | ||
1040 | + | ||
1041 | +fastfloat_really_inline constexpr uint64_t byteswap(uint64_t val) { | ||
1042 | + return (val & 0xFF00000000000000) >> 56 | (val & 0x00FF000000000000) >> 40 | | ||
1043 | + (val & 0x0000FF0000000000) >> 24 | (val & 0x000000FF00000000) >> 8 | | ||
1044 | + (val & 0x00000000FF000000) << 8 | (val & 0x0000000000FF0000) << 24 | | ||
1045 | + (val & 0x000000000000FF00) << 40 | (val & 0x00000000000000FF) << 56; | ||
1046 | +} | ||
1047 | + | ||
1048 | +// Read 8 UC into a u64. Truncates UC if not char. | ||
1049 | +template <typename UC> | ||
1050 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t | ||
1051 | +read8_to_u64(const UC *chars) { | ||
1052 | + if (cpp20_and_in_constexpr() || !std::is_same<UC, char>::value) { | ||
1053 | + uint64_t val = 0; | ||
1054 | + for (int i = 0; i < 8; ++i) { | ||
1055 | + val |= uint64_t(uint8_t(*chars)) << (i * 8); | ||
1056 | + ++chars; | ||
1057 | + } | ||
1058 | + return val; | ||
1059 | + } | ||
1060 | + uint64_t val; | ||
1061 | + ::memcpy(&val, chars, sizeof(uint64_t)); | ||
1062 | +#if FASTFLOAT_IS_BIG_ENDIAN == 1 | ||
1063 | + // Need to read as-if the number was in little-endian order. | ||
1064 | + val = byteswap(val); | ||
1065 | +#endif | ||
1066 | + return val; | ||
1067 | +} | ||
1068 | + | ||
1069 | +#ifdef FASTFLOAT_SSE2 | ||
1070 | + | ||
1071 | +fastfloat_really_inline uint64_t simd_read8_to_u64(const __m128i data) { | ||
1072 | + FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
1073 | + const __m128i packed = _mm_packus_epi16(data, data); | ||
1074 | +#ifdef FASTFLOAT_64BIT | ||
1075 | + return uint64_t(_mm_cvtsi128_si64(packed)); | ||
1076 | +#else | ||
1077 | + uint64_t value; | ||
1078 | + // Visual Studio + older versions of GCC don't support _mm_storeu_si64 | ||
1079 | + _mm_storel_epi64(reinterpret_cast<__m128i *>(&value), packed); | ||
1080 | + return value; | ||
1081 | +#endif | ||
1082 | + FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
1083 | +} | ||
1084 | + | ||
1085 | +fastfloat_really_inline uint64_t simd_read8_to_u64(const char16_t *chars) { | ||
1086 | + FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
1087 | + return simd_read8_to_u64( | ||
1088 | + _mm_loadu_si128(reinterpret_cast<const __m128i *>(chars))); | ||
1089 | + FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
1090 | +} | ||
1091 | + | ||
1092 | +#elif defined(FASTFLOAT_NEON) | ||
1093 | + | ||
1094 | +fastfloat_really_inline uint64_t simd_read8_to_u64(const uint16x8_t data) { | ||
1095 | + FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
1096 | + uint8x8_t utf8_packed = vmovn_u16(data); | ||
1097 | + return vget_lane_u64(vreinterpret_u64_u8(utf8_packed), 0); | ||
1098 | + FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
1099 | +} | ||
1100 | + | ||
1101 | +fastfloat_really_inline uint64_t simd_read8_to_u64(const char16_t *chars) { | ||
1102 | + FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
1103 | + return simd_read8_to_u64( | ||
1104 | + vld1q_u16(reinterpret_cast<const uint16_t *>(chars))); | ||
1105 | + FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
1106 | +} | ||
1107 | + | ||
1108 | +#endif // FASTFLOAT_SSE2 | ||
1109 | + | ||
1110 | +// MSVC SFINAE is broken pre-VS2017 | ||
1111 | +#if defined(_MSC_VER) && _MSC_VER <= 1900 | ||
1112 | +template <typename UC> | ||
1113 | +#else | ||
1114 | +template <typename UC, FASTFLOAT_ENABLE_IF(!has_simd_opt<UC>()) = 0> | ||
1115 | +#endif | ||
1116 | +// dummy for compile | ||
1117 | +uint64_t simd_read8_to_u64(UC const *) { | ||
1118 | + return 0; | ||
1119 | +} | ||
1120 | + | ||
1121 | +// credit @aqrit | ||
1122 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint32_t | ||
1123 | +parse_eight_digits_unrolled(uint64_t val) { | ||
1124 | + const uint64_t mask = 0x000000FF000000FF; | ||
1125 | + const uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32) | ||
1126 | + const uint64_t mul2 = 0x0000271000000001; // 1 + (10000ULL << 32) | ||
1127 | + val -= 0x3030303030303030; | ||
1128 | + val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8; | ||
1129 | + val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32; | ||
1130 | + return uint32_t(val); | ||
1131 | +} | ||
1132 | + | ||
1133 | +// Call this if chars are definitely 8 digits. | ||
1134 | +template <typename UC> | ||
1135 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint32_t | ||
1136 | +parse_eight_digits_unrolled(UC const *chars) noexcept { | ||
1137 | + if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) { | ||
1138 | + return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay | ||
1139 | + } | ||
1140 | + return parse_eight_digits_unrolled(simd_read8_to_u64(chars)); | ||
1141 | +} | ||
1142 | + | ||
1143 | +// credit @aqrit | ||
1144 | +fastfloat_really_inline constexpr bool | ||
1145 | +is_made_of_eight_digits_fast(uint64_t val) noexcept { | ||
1146 | + return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) & | ||
1147 | + 0x8080808080808080)); | ||
1148 | +} | ||
1149 | + | ||
1150 | +#ifdef FASTFLOAT_HAS_SIMD | ||
1151 | + | ||
1152 | +// Call this if chars might not be 8 digits. | ||
1153 | +// Using this style (instead of is_made_of_eight_digits_fast() then | ||
1154 | +// parse_eight_digits_unrolled()) ensures we don't load SIMD registers twice. | ||
1155 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool | ||
1156 | +simd_parse_if_eight_digits_unrolled(const char16_t *chars, | ||
1157 | + uint64_t &i) noexcept { | ||
1158 | + if (cpp20_and_in_constexpr()) { | ||
1159 | + return false; | ||
1160 | + } | ||
1161 | +#ifdef FASTFLOAT_SSE2 | ||
1162 | + FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
1163 | + const __m128i data = | ||
1164 | + _mm_loadu_si128(reinterpret_cast<const __m128i *>(chars)); | ||
1165 | + | ||
1166 | + // (x - '0') <= 9 | ||
1167 | + // http://0x80.pl/articles/simd-parsing-int-sequences.html | ||
1168 | + const __m128i t0 = _mm_add_epi16(data, _mm_set1_epi16(32720)); | ||
1169 | + const __m128i t1 = _mm_cmpgt_epi16(t0, _mm_set1_epi16(-32759)); | ||
1170 | + | ||
1171 | + if (_mm_movemask_epi8(t1) == 0) { | ||
1172 | + i = i * 100000000 + parse_eight_digits_unrolled(simd_read8_to_u64(data)); | ||
1173 | + return true; | ||
1174 | + } else | ||
1175 | + return false; | ||
1176 | + FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
1177 | +#elif defined(FASTFLOAT_NEON) | ||
1178 | + FASTFLOAT_SIMD_DISABLE_WARNINGS | ||
1179 | + const uint16x8_t data = vld1q_u16(reinterpret_cast<const uint16_t *>(chars)); | ||
1180 | + | ||
1181 | + // (x - '0') <= 9 | ||
1182 | + // http://0x80.pl/articles/simd-parsing-int-sequences.html | ||
1183 | + const uint16x8_t t0 = vsubq_u16(data, vmovq_n_u16('0')); | ||
1184 | + const uint16x8_t mask = vcltq_u16(t0, vmovq_n_u16('9' - '0' + 1)); | ||
1185 | + | ||
1186 | + if (vminvq_u16(mask) == 0xFFFF) { | ||
1187 | + i = i * 100000000 + parse_eight_digits_unrolled(simd_read8_to_u64(data)); | ||
1188 | + return true; | ||
1189 | + } else | ||
1190 | + return false; | ||
1191 | + FASTFLOAT_SIMD_RESTORE_WARNINGS | ||
1192 | +#else | ||
1193 | + (void)chars; | ||
1194 | + (void)i; | ||
1195 | + return false; | ||
1196 | +#endif // FASTFLOAT_SSE2 | ||
1197 | +} | ||
1198 | + | ||
1199 | +#endif // FASTFLOAT_HAS_SIMD | ||
1200 | + | ||
1201 | +// MSVC SFINAE is broken pre-VS2017 | ||
1202 | +#if defined(_MSC_VER) && _MSC_VER <= 1900 | ||
1203 | +template <typename UC> | ||
1204 | +#else | ||
1205 | +template <typename UC, FASTFLOAT_ENABLE_IF(!has_simd_opt<UC>()) = 0> | ||
1206 | +#endif | ||
1207 | +// dummy for compile | ||
1208 | +bool simd_parse_if_eight_digits_unrolled(UC const *, uint64_t &) { | ||
1209 | + return 0; | ||
1210 | +} | ||
1211 | + | ||
1212 | +template <typename UC, FASTFLOAT_ENABLE_IF(!std::is_same<UC, char>::value) = 0> | ||
1213 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
1214 | +loop_parse_if_eight_digits(const UC *&p, const UC *const pend, uint64_t &i) { | ||
1215 | + if (!has_simd_opt<UC>()) { | ||
1216 | + return; | ||
1217 | + } | ||
1218 | + while ((std::distance(p, pend) >= 8) && | ||
1219 | + simd_parse_if_eight_digits_unrolled( | ||
1220 | + p, i)) { // in rare cases, this will overflow, but that's ok | ||
1221 | + p += 8; | ||
1222 | + } | ||
1223 | +} | ||
1224 | + | ||
1225 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
1226 | +loop_parse_if_eight_digits(const char *&p, const char *const pend, | ||
1227 | + uint64_t &i) { | ||
1228 | + // optimizes better than parse_if_eight_digits_unrolled() for UC = char. | ||
1229 | + while ((std::distance(p, pend) >= 8) && | ||
1230 | + is_made_of_eight_digits_fast(read8_to_u64(p))) { | ||
1231 | + i = i * 100000000 + | ||
1232 | + parse_eight_digits_unrolled(read8_to_u64( | ||
1233 | + p)); // in rare cases, this will overflow, but that's ok | ||
1234 | + p += 8; | ||
1235 | + } | ||
1236 | +} | ||
1237 | + | ||
1238 | +enum class parse_error { | ||
1239 | + no_error, | ||
1240 | + // [JSON-only] The minus sign must be followed by an integer. | ||
1241 | + missing_integer_after_sign, | ||
1242 | + // A sign must be followed by an integer or dot. | ||
1243 | + missing_integer_or_dot_after_sign, | ||
1244 | + // [JSON-only] The integer part must not have leading zeros. | ||
1245 | + leading_zeros_in_integer_part, | ||
1246 | + // [JSON-only] The integer part must have at least one digit. | ||
1247 | + no_digits_in_integer_part, | ||
1248 | + // [JSON-only] If there is a decimal point, there must be digits in the | ||
1249 | + // fractional part. | ||
1250 | + no_digits_in_fractional_part, | ||
1251 | + // The mantissa must have at least one digit. | ||
1252 | + no_digits_in_mantissa, | ||
1253 | + // Scientific notation requires an exponential part. | ||
1254 | + missing_exponential_part, | ||
1255 | +}; | ||
1256 | + | ||
1257 | +template <typename UC> struct parsed_number_string_t { | ||
1258 | + int64_t exponent{0}; | ||
1259 | + uint64_t mantissa{0}; | ||
1260 | + UC const *lastmatch{nullptr}; | ||
1261 | + bool negative{false}; | ||
1262 | + bool valid{false}; | ||
1263 | + bool too_many_digits{false}; | ||
1264 | + // contains the range of the significant digits | ||
1265 | + span<const UC> integer{}; // non-nullable | ||
1266 | + span<const UC> fraction{}; // nullable | ||
1267 | + parse_error error{parse_error::no_error}; | ||
1268 | +}; | ||
1269 | + | ||
1270 | +using byte_span = span<const char>; | ||
1271 | +using parsed_number_string = parsed_number_string_t<char>; | ||
1272 | + | ||
1273 | +template <typename UC> | ||
1274 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC> | ||
1275 | +report_parse_error(UC const *p, parse_error error) { | ||
1276 | + parsed_number_string_t<UC> answer; | ||
1277 | + answer.valid = false; | ||
1278 | + answer.lastmatch = p; | ||
1279 | + answer.error = error; | ||
1280 | + return answer; | ||
1281 | +} | ||
1282 | + | ||
1283 | +// Assuming that you use no more than 19 digits, this will | ||
1284 | +// parse an ASCII string. | ||
1285 | +template <typename UC> | ||
1286 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t<UC> | ||
1287 | +parse_number_string(UC const *p, UC const *pend, | ||
1288 | + parse_options_t<UC> options) noexcept { | ||
1289 | + chars_format const fmt = options.format; | ||
1290 | + UC const decimal_point = options.decimal_point; | ||
1291 | + | ||
1292 | + parsed_number_string_t<UC> answer; | ||
1293 | + answer.valid = false; | ||
1294 | + answer.too_many_digits = false; | ||
1295 | + answer.negative = (*p == UC('-')); | ||
1296 | +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default | ||
1297 | + if ((*p == UC('-')) || (!(fmt & FASTFLOAT_JSONFMT) && *p == UC('+'))) { | ||
1298 | +#else | ||
1299 | + if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here | ||
1300 | +#endif | ||
1301 | + ++p; | ||
1302 | + if (p == pend) { | ||
1303 | + return report_parse_error<UC>( | ||
1304 | + p, parse_error::missing_integer_or_dot_after_sign); | ||
1305 | + } | ||
1306 | + if (fmt & FASTFLOAT_JSONFMT) { | ||
1307 | + if (!is_integer(*p)) { // a sign must be followed by an integer | ||
1308 | + return report_parse_error<UC>(p, | ||
1309 | + parse_error::missing_integer_after_sign); | ||
1310 | + } | ||
1311 | + } else { | ||
1312 | + if (!is_integer(*p) && | ||
1313 | + (*p != | ||
1314 | + decimal_point)) { // a sign must be followed by an integer or the dot | ||
1315 | + return report_parse_error<UC>( | ||
1316 | + p, parse_error::missing_integer_or_dot_after_sign); | ||
1317 | + } | ||
1318 | + } | ||
1319 | + } | ||
1320 | + UC const *const start_digits = p; | ||
1321 | + | ||
1322 | + uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad) | ||
1323 | + | ||
1324 | + while ((p != pend) && is_integer(*p)) { | ||
1325 | + // a multiplication by 10 is cheaper than an arbitrary integer | ||
1326 | + // multiplication | ||
1327 | + i = 10 * i + | ||
1328 | + uint64_t(*p - | ||
1329 | + UC('0')); // might overflow, we will handle the overflow later | ||
1330 | + ++p; | ||
1331 | + } | ||
1332 | + UC const *const end_of_integer_part = p; | ||
1333 | + int64_t digit_count = int64_t(end_of_integer_part - start_digits); | ||
1334 | + answer.integer = span<const UC>(start_digits, size_t(digit_count)); | ||
1335 | + if (fmt & FASTFLOAT_JSONFMT) { | ||
1336 | + // at least 1 digit in integer part, without leading zeros | ||
1337 | + if (digit_count == 0) { | ||
1338 | + return report_parse_error<UC>(p, parse_error::no_digits_in_integer_part); | ||
1339 | + } | ||
1340 | + if ((start_digits[0] == UC('0') && digit_count > 1)) { | ||
1341 | + return report_parse_error<UC>(start_digits, | ||
1342 | + parse_error::leading_zeros_in_integer_part); | ||
1343 | + } | ||
1344 | + } | ||
1345 | + | ||
1346 | + int64_t exponent = 0; | ||
1347 | + const bool has_decimal_point = (p != pend) && (*p == decimal_point); | ||
1348 | + if (has_decimal_point) { | ||
1349 | + ++p; | ||
1350 | + UC const *before = p; | ||
1351 | + // can occur at most twice without overflowing, but let it occur more, since | ||
1352 | + // for integers with many digits, digit parsing is the primary bottleneck. | ||
1353 | + loop_parse_if_eight_digits(p, pend, i); | ||
1354 | + | ||
1355 | + while ((p != pend) && is_integer(*p)) { | ||
1356 | + uint8_t digit = uint8_t(*p - UC('0')); | ||
1357 | + ++p; | ||
1358 | + i = i * 10 + digit; // in rare cases, this will overflow, but that's ok | ||
1359 | + } | ||
1360 | + exponent = before - p; | ||
1361 | + answer.fraction = span<const UC>(before, size_t(p - before)); | ||
1362 | + digit_count -= exponent; | ||
1363 | + } | ||
1364 | + if (fmt & FASTFLOAT_JSONFMT) { | ||
1365 | + // at least 1 digit in fractional part | ||
1366 | + if (has_decimal_point && exponent == 0) { | ||
1367 | + return report_parse_error<UC>(p, | ||
1368 | + parse_error::no_digits_in_fractional_part); | ||
1369 | + } | ||
1370 | + } else if (digit_count == | ||
1371 | + 0) { // we must have encountered at least one integer! | ||
1372 | + return report_parse_error<UC>(p, parse_error::no_digits_in_mantissa); | ||
1373 | + } | ||
1374 | + int64_t exp_number = 0; // explicit exponential part | ||
1375 | + if (((fmt & chars_format::scientific) && (p != pend) && | ||
1376 | + ((UC('e') == *p) || (UC('E') == *p))) || | ||
1377 | + ((fmt & FASTFLOAT_FORTRANFMT) && (p != pend) && | ||
1378 | + ((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) || | ||
1379 | + (UC('D') == *p)))) { | ||
1380 | + UC const *location_of_e = p; | ||
1381 | + if ((UC('e') == *p) || (UC('E') == *p) || (UC('d') == *p) || | ||
1382 | + (UC('D') == *p)) { | ||
1383 | + ++p; | ||
1384 | + } | ||
1385 | + bool neg_exp = false; | ||
1386 | + if ((p != pend) && (UC('-') == *p)) { | ||
1387 | + neg_exp = true; | ||
1388 | + ++p; | ||
1389 | + } else if ((p != pend) && | ||
1390 | + (UC('+') == | ||
1391 | + *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1) | ||
1392 | + ++p; | ||
1393 | + } | ||
1394 | + if ((p == pend) || !is_integer(*p)) { | ||
1395 | + if (!(fmt & chars_format::fixed)) { | ||
1396 | + // The exponential part is invalid for scientific notation, so it must | ||
1397 | + // be a trailing token for fixed notation. However, fixed notation is | ||
1398 | + // disabled, so report a scientific notation error. | ||
1399 | + return report_parse_error<UC>(p, parse_error::missing_exponential_part); | ||
1400 | + } | ||
1401 | + // Otherwise, we will be ignoring the 'e'. | ||
1402 | + p = location_of_e; | ||
1403 | + } else { | ||
1404 | + while ((p != pend) && is_integer(*p)) { | ||
1405 | + uint8_t digit = uint8_t(*p - UC('0')); | ||
1406 | + if (exp_number < 0x10000000) { | ||
1407 | + exp_number = 10 * exp_number + digit; | ||
1408 | + } | ||
1409 | + ++p; | ||
1410 | + } | ||
1411 | + if (neg_exp) { | ||
1412 | + exp_number = -exp_number; | ||
1413 | + } | ||
1414 | + exponent += exp_number; | ||
1415 | + } | ||
1416 | + } else { | ||
1417 | + // If it scientific and not fixed, we have to bail out. | ||
1418 | + if ((fmt & chars_format::scientific) && !(fmt & chars_format::fixed)) { | ||
1419 | + return report_parse_error<UC>(p, parse_error::missing_exponential_part); | ||
1420 | + } | ||
1421 | + } | ||
1422 | + answer.lastmatch = p; | ||
1423 | + answer.valid = true; | ||
1424 | + | ||
1425 | + // If we frequently had to deal with long strings of digits, | ||
1426 | + // we could extend our code by using a 128-bit integer instead | ||
1427 | + // of a 64-bit integer. However, this is uncommon. | ||
1428 | + // | ||
1429 | + // We can deal with up to 19 digits. | ||
1430 | + if (digit_count > 19) { // this is uncommon | ||
1431 | + // It is possible that the integer had an overflow. | ||
1432 | + // We have to handle the case where we have 0.0000somenumber. | ||
1433 | + // We need to be mindful of the case where we only have zeroes... | ||
1434 | + // E.g., 0.000000000...000. | ||
1435 | + UC const *start = start_digits; | ||
1436 | + while ((start != pend) && (*start == UC('0') || *start == decimal_point)) { | ||
1437 | + if (*start == UC('0')) { | ||
1438 | + digit_count--; | ||
1439 | + } | ||
1440 | + start++; | ||
1441 | + } | ||
1442 | + | ||
1443 | + if (digit_count > 19) { | ||
1444 | + answer.too_many_digits = true; | ||
1445 | + // Let us start again, this time, avoiding overflows. | ||
1446 | + // We don't need to check if is_integer, since we use the | ||
1447 | + // pre-tokenized spans from above. | ||
1448 | + i = 0; | ||
1449 | + p = answer.integer.ptr; | ||
1450 | + UC const *int_end = p + answer.integer.len(); | ||
1451 | + const uint64_t minimal_nineteen_digit_integer{1000000000000000000}; | ||
1452 | + while ((i < minimal_nineteen_digit_integer) && (p != int_end)) { | ||
1453 | + i = i * 10 + uint64_t(*p - UC('0')); | ||
1454 | + ++p; | ||
1455 | + } | ||
1456 | + if (i >= minimal_nineteen_digit_integer) { // We have a big integers | ||
1457 | + exponent = end_of_integer_part - p + exp_number; | ||
1458 | + } else { // We have a value with a fractional component. | ||
1459 | + p = answer.fraction.ptr; | ||
1460 | + UC const *frac_end = p + answer.fraction.len(); | ||
1461 | + while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) { | ||
1462 | + i = i * 10 + uint64_t(*p - UC('0')); | ||
1463 | + ++p; | ||
1464 | + } | ||
1465 | + exponent = answer.fraction.ptr - p + exp_number; | ||
1466 | + } | ||
1467 | + // We have now corrected both exponent and i, to a truncated value | ||
1468 | + } | ||
1469 | + } | ||
1470 | + answer.exponent = exponent; | ||
1471 | + answer.mantissa = i; | ||
1472 | + return answer; | ||
1473 | +} | ||
1474 | + | ||
1475 | +template <typename T, typename UC> | ||
1476 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
1477 | +parse_int_string(UC const *p, UC const *pend, T &value, int base) { | ||
1478 | + from_chars_result_t<UC> answer; | ||
1479 | + | ||
1480 | + UC const *const first = p; | ||
1481 | + | ||
1482 | + bool negative = (*p == UC('-')); | ||
1483 | + if (!std::is_signed<T>::value && negative) { | ||
1484 | + answer.ec = std::errc::invalid_argument; | ||
1485 | + answer.ptr = first; | ||
1486 | + return answer; | ||
1487 | + } | ||
1488 | +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default | ||
1489 | + if ((*p == UC('-')) || (*p == UC('+'))) { | ||
1490 | +#else | ||
1491 | + if (*p == UC('-')) { | ||
1492 | +#endif | ||
1493 | + ++p; | ||
1494 | + } | ||
1495 | + | ||
1496 | + UC const *const start_num = p; | ||
1497 | + | ||
1498 | + while (p != pend && *p == UC('0')) { | ||
1499 | + ++p; | ||
1500 | + } | ||
1501 | + | ||
1502 | + const bool has_leading_zeros = p > start_num; | ||
1503 | + | ||
1504 | + UC const *const start_digits = p; | ||
1505 | + | ||
1506 | + uint64_t i = 0; | ||
1507 | + if (base == 10) { | ||
1508 | + loop_parse_if_eight_digits(p, pend, i); // use SIMD if possible | ||
1509 | + } | ||
1510 | + while (p != pend) { | ||
1511 | + uint8_t digit = ch_to_digit(*p); | ||
1512 | + if (digit >= base) { | ||
1513 | + break; | ||
1514 | + } | ||
1515 | + i = uint64_t(base) * i + digit; // might overflow, check this later | ||
1516 | + p++; | ||
1517 | + } | ||
1518 | + | ||
1519 | + size_t digit_count = size_t(p - start_digits); | ||
1520 | + | ||
1521 | + if (digit_count == 0) { | ||
1522 | + if (has_leading_zeros) { | ||
1523 | + value = 0; | ||
1524 | + answer.ec = std::errc(); | ||
1525 | + answer.ptr = p; | ||
1526 | + } else { | ||
1527 | + answer.ec = std::errc::invalid_argument; | ||
1528 | + answer.ptr = first; | ||
1529 | + } | ||
1530 | + return answer; | ||
1531 | + } | ||
1532 | + | ||
1533 | + answer.ptr = p; | ||
1534 | + | ||
1535 | + // check u64 overflow | ||
1536 | + size_t max_digits = max_digits_u64(base); | ||
1537 | + if (digit_count > max_digits) { | ||
1538 | + answer.ec = std::errc::result_out_of_range; | ||
1539 | + return answer; | ||
1540 | + } | ||
1541 | + // this check can be eliminated for all other types, but they will all require | ||
1542 | + // a max_digits(base) equivalent | ||
1543 | + if (digit_count == max_digits && i < min_safe_u64(base)) { | ||
1544 | + answer.ec = std::errc::result_out_of_range; | ||
1545 | + return answer; | ||
1546 | + } | ||
1547 | + | ||
1548 | + // check other types overflow | ||
1549 | + if (!std::is_same<T, uint64_t>::value) { | ||
1550 | + if (i > uint64_t(std::numeric_limits<T>::max()) + uint64_t(negative)) { | ||
1551 | + answer.ec = std::errc::result_out_of_range; | ||
1552 | + return answer; | ||
1553 | + } | ||
1554 | + } | ||
1555 | + | ||
1556 | + if (negative) { | ||
1557 | +#ifdef FASTFLOAT_VISUAL_STUDIO | ||
1558 | +#pragma warning(push) | ||
1559 | +#pragma warning(disable : 4146) | ||
1560 | +#endif | ||
1561 | + // this weird workaround is required because: | ||
1562 | + // - converting unsigned to signed when its value is greater than signed max | ||
1563 | + // is UB pre-C++23. | ||
1564 | + // - reinterpret_casting (~i + 1) would work, but it is not constexpr | ||
1565 | + // this is always optimized into a neg instruction (note: T is an integer | ||
1566 | + // type) | ||
1567 | + value = T(-std::numeric_limits<T>::max() - | ||
1568 | + T(i - uint64_t(std::numeric_limits<T>::max()))); | ||
1569 | +#ifdef FASTFLOAT_VISUAL_STUDIO | ||
1570 | +#pragma warning(pop) | ||
1571 | +#endif | ||
1572 | + } else { | ||
1573 | + value = T(i); | ||
1574 | + } | ||
1575 | + | ||
1576 | + answer.ec = std::errc(); | ||
1577 | + return answer; | ||
1578 | +} | ||
1579 | + | ||
1580 | +} // namespace fast_float | ||
1581 | + | ||
1582 | +#endif | ||
1583 | + | ||
1584 | +#ifndef FASTFLOAT_FAST_TABLE_H | ||
1585 | +#define FASTFLOAT_FAST_TABLE_H | ||
1586 | + | ||
1587 | +#include <cstdint> | ||
1588 | + | ||
1589 | +namespace fast_float { | ||
1590 | + | ||
1591 | +/** | ||
1592 | + * When mapping numbers from decimal to binary, | ||
1593 | + * we go from w * 10^q to m * 2^p but we have | ||
1594 | + * 10^q = 5^q * 2^q, so effectively | ||
1595 | + * we are trying to match | ||
1596 | + * w * 2^q * 5^q to m * 2^p. Thus the powers of two | ||
1597 | + * are not a concern since they can be represented | ||
1598 | + * exactly using the binary notation, only the powers of five | ||
1599 | + * affect the binary significand. | ||
1600 | + */ | ||
1601 | + | ||
1602 | +/** | ||
1603 | + * The smallest non-zero float (binary64) is 2^-1074. | ||
1604 | + * We take as input numbers of the form w x 10^q where w < 2^64. | ||
1605 | + * We have that w * 10^-343 < 2^(64-344) 5^-343 < 2^-1076. | ||
1606 | + * However, we have that | ||
1607 | + * (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^-1074. | ||
1608 | + * Thus it is possible for a number of the form w * 10^-342 where | ||
1609 | + * w is a 64-bit value to be a non-zero floating-point number. | ||
1610 | + ********* | ||
1611 | + * Any number of form w * 10^309 where w>= 1 is going to be | ||
1612 | + * infinite in binary64 so we never need to worry about powers | ||
1613 | + * of 5 greater than 308. | ||
1614 | + */ | ||
1615 | +template <class unused = void> struct powers_template { | ||
1616 | + | ||
1617 | + constexpr static int smallest_power_of_five = | ||
1618 | + binary_format<double>::smallest_power_of_ten(); | ||
1619 | + constexpr static int largest_power_of_five = | ||
1620 | + binary_format<double>::largest_power_of_ten(); | ||
1621 | + constexpr static int number_of_entries = | ||
1622 | + 2 * (largest_power_of_five - smallest_power_of_five + 1); | ||
1623 | + // Powers of five from 5^-342 all the way to 5^308 rounded toward one. | ||
1624 | + constexpr static uint64_t power_of_five_128[number_of_entries] = { | ||
1625 | + 0xeef453d6923bd65a, 0x113faa2906a13b3f, | ||
1626 | + 0x9558b4661b6565f8, 0x4ac7ca59a424c507, | ||
1627 | + 0xbaaee17fa23ebf76, 0x5d79bcf00d2df649, | ||
1628 | + 0xe95a99df8ace6f53, 0xf4d82c2c107973dc, | ||
1629 | + 0x91d8a02bb6c10594, 0x79071b9b8a4be869, | ||
1630 | + 0xb64ec836a47146f9, 0x9748e2826cdee284, | ||
1631 | + 0xe3e27a444d8d98b7, 0xfd1b1b2308169b25, | ||
1632 | + 0x8e6d8c6ab0787f72, 0xfe30f0f5e50e20f7, | ||
1633 | + 0xb208ef855c969f4f, 0xbdbd2d335e51a935, | ||
1634 | + 0xde8b2b66b3bc4723, 0xad2c788035e61382, | ||
1635 | + 0x8b16fb203055ac76, 0x4c3bcb5021afcc31, | ||
1636 | + 0xaddcb9e83c6b1793, 0xdf4abe242a1bbf3d, | ||
1637 | + 0xd953e8624b85dd78, 0xd71d6dad34a2af0d, | ||
1638 | + 0x87d4713d6f33aa6b, 0x8672648c40e5ad68, | ||
1639 | + 0xa9c98d8ccb009506, 0x680efdaf511f18c2, | ||
1640 | + 0xd43bf0effdc0ba48, 0x212bd1b2566def2, | ||
1641 | + 0x84a57695fe98746d, 0x14bb630f7604b57, | ||
1642 | + 0xa5ced43b7e3e9188, 0x419ea3bd35385e2d, | ||
1643 | + 0xcf42894a5dce35ea, 0x52064cac828675b9, | ||
1644 | + 0x818995ce7aa0e1b2, 0x7343efebd1940993, | ||
1645 | + 0xa1ebfb4219491a1f, 0x1014ebe6c5f90bf8, | ||
1646 | + 0xca66fa129f9b60a6, 0xd41a26e077774ef6, | ||
1647 | + 0xfd00b897478238d0, 0x8920b098955522b4, | ||
1648 | + 0x9e20735e8cb16382, 0x55b46e5f5d5535b0, | ||
1649 | + 0xc5a890362fddbc62, 0xeb2189f734aa831d, | ||
1650 | + 0xf712b443bbd52b7b, 0xa5e9ec7501d523e4, | ||
1651 | + 0x9a6bb0aa55653b2d, 0x47b233c92125366e, | ||
1652 | + 0xc1069cd4eabe89f8, 0x999ec0bb696e840a, | ||
1653 | + 0xf148440a256e2c76, 0xc00670ea43ca250d, | ||
1654 | + 0x96cd2a865764dbca, 0x380406926a5e5728, | ||
1655 | + 0xbc807527ed3e12bc, 0xc605083704f5ecf2, | ||
1656 | + 0xeba09271e88d976b, 0xf7864a44c633682e, | ||
1657 | + 0x93445b8731587ea3, 0x7ab3ee6afbe0211d, | ||
1658 | + 0xb8157268fdae9e4c, 0x5960ea05bad82964, | ||
1659 | + 0xe61acf033d1a45df, 0x6fb92487298e33bd, | ||
1660 | + 0x8fd0c16206306bab, 0xa5d3b6d479f8e056, | ||
1661 | + 0xb3c4f1ba87bc8696, 0x8f48a4899877186c, | ||
1662 | + 0xe0b62e2929aba83c, 0x331acdabfe94de87, | ||
1663 | + 0x8c71dcd9ba0b4925, 0x9ff0c08b7f1d0b14, | ||
1664 | + 0xaf8e5410288e1b6f, 0x7ecf0ae5ee44dd9, | ||
1665 | + 0xdb71e91432b1a24a, 0xc9e82cd9f69d6150, | ||
1666 | + 0x892731ac9faf056e, 0xbe311c083a225cd2, | ||
1667 | + 0xab70fe17c79ac6ca, 0x6dbd630a48aaf406, | ||
1668 | + 0xd64d3d9db981787d, 0x92cbbccdad5b108, | ||
1669 | + 0x85f0468293f0eb4e, 0x25bbf56008c58ea5, | ||
1670 | + 0xa76c582338ed2621, 0xaf2af2b80af6f24e, | ||
1671 | + 0xd1476e2c07286faa, 0x1af5af660db4aee1, | ||
1672 | + 0x82cca4db847945ca, 0x50d98d9fc890ed4d, | ||
1673 | + 0xa37fce126597973c, 0xe50ff107bab528a0, | ||
1674 | + 0xcc5fc196fefd7d0c, 0x1e53ed49a96272c8, | ||
1675 | + 0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7a, | ||
1676 | + 0x9faacf3df73609b1, 0x77b191618c54e9ac, | ||
1677 | + 0xc795830d75038c1d, 0xd59df5b9ef6a2417, | ||
1678 | + 0xf97ae3d0d2446f25, 0x4b0573286b44ad1d, | ||
1679 | + 0x9becce62836ac577, 0x4ee367f9430aec32, | ||
1680 | + 0xc2e801fb244576d5, 0x229c41f793cda73f, | ||
1681 | + 0xf3a20279ed56d48a, 0x6b43527578c1110f, | ||
1682 | + 0x9845418c345644d6, 0x830a13896b78aaa9, | ||
1683 | + 0xbe5691ef416bd60c, 0x23cc986bc656d553, | ||
1684 | + 0xedec366b11c6cb8f, 0x2cbfbe86b7ec8aa8, | ||
1685 | + 0x94b3a202eb1c3f39, 0x7bf7d71432f3d6a9, | ||
1686 | + 0xb9e08a83a5e34f07, 0xdaf5ccd93fb0cc53, | ||
1687 | + 0xe858ad248f5c22c9, 0xd1b3400f8f9cff68, | ||
1688 | + 0x91376c36d99995be, 0x23100809b9c21fa1, | ||
1689 | + 0xb58547448ffffb2d, 0xabd40a0c2832a78a, | ||
1690 | + 0xe2e69915b3fff9f9, 0x16c90c8f323f516c, | ||
1691 | + 0x8dd01fad907ffc3b, 0xae3da7d97f6792e3, | ||
1692 | + 0xb1442798f49ffb4a, 0x99cd11cfdf41779c, | ||
1693 | + 0xdd95317f31c7fa1d, 0x40405643d711d583, | ||
1694 | + 0x8a7d3eef7f1cfc52, 0x482835ea666b2572, | ||
1695 | + 0xad1c8eab5ee43b66, 0xda3243650005eecf, | ||
1696 | + 0xd863b256369d4a40, 0x90bed43e40076a82, | ||
1697 | + 0x873e4f75e2224e68, 0x5a7744a6e804a291, | ||
1698 | + 0xa90de3535aaae202, 0x711515d0a205cb36, | ||
1699 | + 0xd3515c2831559a83, 0xd5a5b44ca873e03, | ||
1700 | + 0x8412d9991ed58091, 0xe858790afe9486c2, | ||
1701 | + 0xa5178fff668ae0b6, 0x626e974dbe39a872, | ||
1702 | + 0xce5d73ff402d98e3, 0xfb0a3d212dc8128f, | ||
1703 | + 0x80fa687f881c7f8e, 0x7ce66634bc9d0b99, | ||
1704 | + 0xa139029f6a239f72, 0x1c1fffc1ebc44e80, | ||
1705 | + 0xc987434744ac874e, 0xa327ffb266b56220, | ||
1706 | + 0xfbe9141915d7a922, 0x4bf1ff9f0062baa8, | ||
1707 | + 0x9d71ac8fada6c9b5, 0x6f773fc3603db4a9, | ||
1708 | + 0xc4ce17b399107c22, 0xcb550fb4384d21d3, | ||
1709 | + 0xf6019da07f549b2b, 0x7e2a53a146606a48, | ||
1710 | + 0x99c102844f94e0fb, 0x2eda7444cbfc426d, | ||
1711 | + 0xc0314325637a1939, 0xfa911155fefb5308, | ||
1712 | + 0xf03d93eebc589f88, 0x793555ab7eba27ca, | ||
1713 | + 0x96267c7535b763b5, 0x4bc1558b2f3458de, | ||
1714 | + 0xbbb01b9283253ca2, 0x9eb1aaedfb016f16, | ||
1715 | + 0xea9c227723ee8bcb, 0x465e15a979c1cadc, | ||
1716 | + 0x92a1958a7675175f, 0xbfacd89ec191ec9, | ||
1717 | + 0xb749faed14125d36, 0xcef980ec671f667b, | ||
1718 | + 0xe51c79a85916f484, 0x82b7e12780e7401a, | ||
1719 | + 0x8f31cc0937ae58d2, 0xd1b2ecb8b0908810, | ||
1720 | + 0xb2fe3f0b8599ef07, 0x861fa7e6dcb4aa15, | ||
1721 | + 0xdfbdcece67006ac9, 0x67a791e093e1d49a, | ||
1722 | + 0x8bd6a141006042bd, 0xe0c8bb2c5c6d24e0, | ||
1723 | + 0xaecc49914078536d, 0x58fae9f773886e18, | ||
1724 | + 0xda7f5bf590966848, 0xaf39a475506a899e, | ||
1725 | + 0x888f99797a5e012d, 0x6d8406c952429603, | ||
1726 | + 0xaab37fd7d8f58178, 0xc8e5087ba6d33b83, | ||
1727 | + 0xd5605fcdcf32e1d6, 0xfb1e4a9a90880a64, | ||
1728 | + 0x855c3be0a17fcd26, 0x5cf2eea09a55067f, | ||
1729 | + 0xa6b34ad8c9dfc06f, 0xf42faa48c0ea481e, | ||
1730 | + 0xd0601d8efc57b08b, 0xf13b94daf124da26, | ||
1731 | + 0x823c12795db6ce57, 0x76c53d08d6b70858, | ||
1732 | + 0xa2cb1717b52481ed, 0x54768c4b0c64ca6e, | ||
1733 | + 0xcb7ddcdda26da268, 0xa9942f5dcf7dfd09, | ||
1734 | + 0xfe5d54150b090b02, 0xd3f93b35435d7c4c, | ||
1735 | + 0x9efa548d26e5a6e1, 0xc47bc5014a1a6daf, | ||
1736 | + 0xc6b8e9b0709f109a, 0x359ab6419ca1091b, | ||
1737 | + 0xf867241c8cc6d4c0, 0xc30163d203c94b62, | ||
1738 | + 0x9b407691d7fc44f8, 0x79e0de63425dcf1d, | ||
1739 | + 0xc21094364dfb5636, 0x985915fc12f542e4, | ||
1740 | + 0xf294b943e17a2bc4, 0x3e6f5b7b17b2939d, | ||
1741 | + 0x979cf3ca6cec5b5a, 0xa705992ceecf9c42, | ||
1742 | + 0xbd8430bd08277231, 0x50c6ff782a838353, | ||
1743 | + 0xece53cec4a314ebd, 0xa4f8bf5635246428, | ||
1744 | + 0x940f4613ae5ed136, 0x871b7795e136be99, | ||
1745 | + 0xb913179899f68584, 0x28e2557b59846e3f, | ||
1746 | + 0xe757dd7ec07426e5, 0x331aeada2fe589cf, | ||
1747 | + 0x9096ea6f3848984f, 0x3ff0d2c85def7621, | ||
1748 | + 0xb4bca50b065abe63, 0xfed077a756b53a9, | ||
1749 | + 0xe1ebce4dc7f16dfb, 0xd3e8495912c62894, | ||
1750 | + 0x8d3360f09cf6e4bd, 0x64712dd7abbbd95c, | ||
1751 | + 0xb080392cc4349dec, 0xbd8d794d96aacfb3, | ||
1752 | + 0xdca04777f541c567, 0xecf0d7a0fc5583a0, | ||
1753 | + 0x89e42caaf9491b60, 0xf41686c49db57244, | ||
1754 | + 0xac5d37d5b79b6239, 0x311c2875c522ced5, | ||
1755 | + 0xd77485cb25823ac7, 0x7d633293366b828b, | ||
1756 | + 0x86a8d39ef77164bc, 0xae5dff9c02033197, | ||
1757 | + 0xa8530886b54dbdeb, 0xd9f57f830283fdfc, | ||
1758 | + 0xd267caa862a12d66, 0xd072df63c324fd7b, | ||
1759 | + 0x8380dea93da4bc60, 0x4247cb9e59f71e6d, | ||
1760 | + 0xa46116538d0deb78, 0x52d9be85f074e608, | ||
1761 | + 0xcd795be870516656, 0x67902e276c921f8b, | ||
1762 | + 0x806bd9714632dff6, 0xba1cd8a3db53b6, | ||
1763 | + 0xa086cfcd97bf97f3, 0x80e8a40eccd228a4, | ||
1764 | + 0xc8a883c0fdaf7df0, 0x6122cd128006b2cd, | ||
1765 | + 0xfad2a4b13d1b5d6c, 0x796b805720085f81, | ||
1766 | + 0x9cc3a6eec6311a63, 0xcbe3303674053bb0, | ||
1767 | + 0xc3f490aa77bd60fc, 0xbedbfc4411068a9c, | ||
1768 | + 0xf4f1b4d515acb93b, 0xee92fb5515482d44, | ||
1769 | + 0x991711052d8bf3c5, 0x751bdd152d4d1c4a, | ||
1770 | + 0xbf5cd54678eef0b6, 0xd262d45a78a0635d, | ||
1771 | + 0xef340a98172aace4, 0x86fb897116c87c34, | ||
1772 | + 0x9580869f0e7aac0e, 0xd45d35e6ae3d4da0, | ||
1773 | + 0xbae0a846d2195712, 0x8974836059cca109, | ||
1774 | + 0xe998d258869facd7, 0x2bd1a438703fc94b, | ||
1775 | + 0x91ff83775423cc06, 0x7b6306a34627ddcf, | ||
1776 | + 0xb67f6455292cbf08, 0x1a3bc84c17b1d542, | ||
1777 | + 0xe41f3d6a7377eeca, 0x20caba5f1d9e4a93, | ||
1778 | + 0x8e938662882af53e, 0x547eb47b7282ee9c, | ||
1779 | + 0xb23867fb2a35b28d, 0xe99e619a4f23aa43, | ||
1780 | + 0xdec681f9f4c31f31, 0x6405fa00e2ec94d4, | ||
1781 | + 0x8b3c113c38f9f37e, 0xde83bc408dd3dd04, | ||
1782 | + 0xae0b158b4738705e, 0x9624ab50b148d445, | ||
1783 | + 0xd98ddaee19068c76, 0x3badd624dd9b0957, | ||
1784 | + 0x87f8a8d4cfa417c9, 0xe54ca5d70a80e5d6, | ||
1785 | + 0xa9f6d30a038d1dbc, 0x5e9fcf4ccd211f4c, | ||
1786 | + 0xd47487cc8470652b, 0x7647c3200069671f, | ||
1787 | + 0x84c8d4dfd2c63f3b, 0x29ecd9f40041e073, | ||
1788 | + 0xa5fb0a17c777cf09, 0xf468107100525890, | ||
1789 | + 0xcf79cc9db955c2cc, 0x7182148d4066eeb4, | ||
1790 | + 0x81ac1fe293d599bf, 0xc6f14cd848405530, | ||
1791 | + 0xa21727db38cb002f, 0xb8ada00e5a506a7c, | ||
1792 | + 0xca9cf1d206fdc03b, 0xa6d90811f0e4851c, | ||
1793 | + 0xfd442e4688bd304a, 0x908f4a166d1da663, | ||
1794 | + 0x9e4a9cec15763e2e, 0x9a598e4e043287fe, | ||
1795 | + 0xc5dd44271ad3cdba, 0x40eff1e1853f29fd, | ||
1796 | + 0xf7549530e188c128, 0xd12bee59e68ef47c, | ||
1797 | + 0x9a94dd3e8cf578b9, 0x82bb74f8301958ce, | ||
1798 | + 0xc13a148e3032d6e7, 0xe36a52363c1faf01, | ||
1799 | + 0xf18899b1bc3f8ca1, 0xdc44e6c3cb279ac1, | ||
1800 | + 0x96f5600f15a7b7e5, 0x29ab103a5ef8c0b9, | ||
1801 | + 0xbcb2b812db11a5de, 0x7415d448f6b6f0e7, | ||
1802 | + 0xebdf661791d60f56, 0x111b495b3464ad21, | ||
1803 | + 0x936b9fcebb25c995, 0xcab10dd900beec34, | ||
1804 | + 0xb84687c269ef3bfb, 0x3d5d514f40eea742, | ||
1805 | + 0xe65829b3046b0afa, 0xcb4a5a3112a5112, | ||
1806 | + 0x8ff71a0fe2c2e6dc, 0x47f0e785eaba72ab, | ||
1807 | + 0xb3f4e093db73a093, 0x59ed216765690f56, | ||
1808 | + 0xe0f218b8d25088b8, 0x306869c13ec3532c, | ||
1809 | + 0x8c974f7383725573, 0x1e414218c73a13fb, | ||
1810 | + 0xafbd2350644eeacf, 0xe5d1929ef90898fa, | ||
1811 | + 0xdbac6c247d62a583, 0xdf45f746b74abf39, | ||
1812 | + 0x894bc396ce5da772, 0x6b8bba8c328eb783, | ||
1813 | + 0xab9eb47c81f5114f, 0x66ea92f3f326564, | ||
1814 | + 0xd686619ba27255a2, 0xc80a537b0efefebd, | ||
1815 | + 0x8613fd0145877585, 0xbd06742ce95f5f36, | ||
1816 | + 0xa798fc4196e952e7, 0x2c48113823b73704, | ||
1817 | + 0xd17f3b51fca3a7a0, 0xf75a15862ca504c5, | ||
1818 | + 0x82ef85133de648c4, 0x9a984d73dbe722fb, | ||
1819 | + 0xa3ab66580d5fdaf5, 0xc13e60d0d2e0ebba, | ||
1820 | + 0xcc963fee10b7d1b3, 0x318df905079926a8, | ||
1821 | + 0xffbbcfe994e5c61f, 0xfdf17746497f7052, | ||
1822 | + 0x9fd561f1fd0f9bd3, 0xfeb6ea8bedefa633, | ||
1823 | + 0xc7caba6e7c5382c8, 0xfe64a52ee96b8fc0, | ||
1824 | + 0xf9bd690a1b68637b, 0x3dfdce7aa3c673b0, | ||
1825 | + 0x9c1661a651213e2d, 0x6bea10ca65c084e, | ||
1826 | + 0xc31bfa0fe5698db8, 0x486e494fcff30a62, | ||
1827 | + 0xf3e2f893dec3f126, 0x5a89dba3c3efccfa, | ||
1828 | + 0x986ddb5c6b3a76b7, 0xf89629465a75e01c, | ||
1829 | + 0xbe89523386091465, 0xf6bbb397f1135823, | ||
1830 | + 0xee2ba6c0678b597f, 0x746aa07ded582e2c, | ||
1831 | + 0x94db483840b717ef, 0xa8c2a44eb4571cdc, | ||
1832 | + 0xba121a4650e4ddeb, 0x92f34d62616ce413, | ||
1833 | + 0xe896a0d7e51e1566, 0x77b020baf9c81d17, | ||
1834 | + 0x915e2486ef32cd60, 0xace1474dc1d122e, | ||
1835 | + 0xb5b5ada8aaff80b8, 0xd819992132456ba, | ||
1836 | + 0xe3231912d5bf60e6, 0x10e1fff697ed6c69, | ||
1837 | + 0x8df5efabc5979c8f, 0xca8d3ffa1ef463c1, | ||
1838 | + 0xb1736b96b6fd83b3, 0xbd308ff8a6b17cb2, | ||
1839 | + 0xddd0467c64bce4a0, 0xac7cb3f6d05ddbde, | ||
1840 | + 0x8aa22c0dbef60ee4, 0x6bcdf07a423aa96b, | ||
1841 | + 0xad4ab7112eb3929d, 0x86c16c98d2c953c6, | ||
1842 | + 0xd89d64d57a607744, 0xe871c7bf077ba8b7, | ||
1843 | + 0x87625f056c7c4a8b, 0x11471cd764ad4972, | ||
1844 | + 0xa93af6c6c79b5d2d, 0xd598e40d3dd89bcf, | ||
1845 | + 0xd389b47879823479, 0x4aff1d108d4ec2c3, | ||
1846 | + 0x843610cb4bf160cb, 0xcedf722a585139ba, | ||
1847 | + 0xa54394fe1eedb8fe, 0xc2974eb4ee658828, | ||
1848 | + 0xce947a3da6a9273e, 0x733d226229feea32, | ||
1849 | + 0x811ccc668829b887, 0x806357d5a3f525f, | ||
1850 | + 0xa163ff802a3426a8, 0xca07c2dcb0cf26f7, | ||
1851 | + 0xc9bcff6034c13052, 0xfc89b393dd02f0b5, | ||
1852 | + 0xfc2c3f3841f17c67, 0xbbac2078d443ace2, | ||
1853 | + 0x9d9ba7832936edc0, 0xd54b944b84aa4c0d, | ||
1854 | + 0xc5029163f384a931, 0xa9e795e65d4df11, | ||
1855 | + 0xf64335bcf065d37d, 0x4d4617b5ff4a16d5, | ||
1856 | + 0x99ea0196163fa42e, 0x504bced1bf8e4e45, | ||
1857 | + 0xc06481fb9bcf8d39, 0xe45ec2862f71e1d6, | ||
1858 | + 0xf07da27a82c37088, 0x5d767327bb4e5a4c, | ||
1859 | + 0x964e858c91ba2655, 0x3a6a07f8d510f86f, | ||
1860 | + 0xbbe226efb628afea, 0x890489f70a55368b, | ||
1861 | + 0xeadab0aba3b2dbe5, 0x2b45ac74ccea842e, | ||
1862 | + 0x92c8ae6b464fc96f, 0x3b0b8bc90012929d, | ||
1863 | + 0xb77ada0617e3bbcb, 0x9ce6ebb40173744, | ||
1864 | + 0xe55990879ddcaabd, 0xcc420a6a101d0515, | ||
1865 | + 0x8f57fa54c2a9eab6, 0x9fa946824a12232d, | ||
1866 | + 0xb32df8e9f3546564, 0x47939822dc96abf9, | ||
1867 | + 0xdff9772470297ebd, 0x59787e2b93bc56f7, | ||
1868 | + 0x8bfbea76c619ef36, 0x57eb4edb3c55b65a, | ||
1869 | + 0xaefae51477a06b03, 0xede622920b6b23f1, | ||
1870 | + 0xdab99e59958885c4, 0xe95fab368e45eced, | ||
1871 | + 0x88b402f7fd75539b, 0x11dbcb0218ebb414, | ||
1872 | + 0xaae103b5fcd2a881, 0xd652bdc29f26a119, | ||
1873 | + 0xd59944a37c0752a2, 0x4be76d3346f0495f, | ||
1874 | + 0x857fcae62d8493a5, 0x6f70a4400c562ddb, | ||
1875 | + 0xa6dfbd9fb8e5b88e, 0xcb4ccd500f6bb952, | ||
1876 | + 0xd097ad07a71f26b2, 0x7e2000a41346a7a7, | ||
1877 | + 0x825ecc24c873782f, 0x8ed400668c0c28c8, | ||
1878 | + 0xa2f67f2dfa90563b, 0x728900802f0f32fa, | ||
1879 | + 0xcbb41ef979346bca, 0x4f2b40a03ad2ffb9, | ||
1880 | + 0xfea126b7d78186bc, 0xe2f610c84987bfa8, | ||
1881 | + 0x9f24b832e6b0f436, 0xdd9ca7d2df4d7c9, | ||
1882 | + 0xc6ede63fa05d3143, 0x91503d1c79720dbb, | ||
1883 | + 0xf8a95fcf88747d94, 0x75a44c6397ce912a, | ||
1884 | + 0x9b69dbe1b548ce7c, 0xc986afbe3ee11aba, | ||
1885 | + 0xc24452da229b021b, 0xfbe85badce996168, | ||
1886 | + 0xf2d56790ab41c2a2, 0xfae27299423fb9c3, | ||
1887 | + 0x97c560ba6b0919a5, 0xdccd879fc967d41a, | ||
1888 | + 0xbdb6b8e905cb600f, 0x5400e987bbc1c920, | ||
1889 | + 0xed246723473e3813, 0x290123e9aab23b68, | ||
1890 | + 0x9436c0760c86e30b, 0xf9a0b6720aaf6521, | ||
1891 | + 0xb94470938fa89bce, 0xf808e40e8d5b3e69, | ||
1892 | + 0xe7958cb87392c2c2, 0xb60b1d1230b20e04, | ||
1893 | + 0x90bd77f3483bb9b9, 0xb1c6f22b5e6f48c2, | ||
1894 | + 0xb4ecd5f01a4aa828, 0x1e38aeb6360b1af3, | ||
1895 | + 0xe2280b6c20dd5232, 0x25c6da63c38de1b0, | ||
1896 | + 0x8d590723948a535f, 0x579c487e5a38ad0e, | ||
1897 | + 0xb0af48ec79ace837, 0x2d835a9df0c6d851, | ||
1898 | + 0xdcdb1b2798182244, 0xf8e431456cf88e65, | ||
1899 | + 0x8a08f0f8bf0f156b, 0x1b8e9ecb641b58ff, | ||
1900 | + 0xac8b2d36eed2dac5, 0xe272467e3d222f3f, | ||
1901 | + 0xd7adf884aa879177, 0x5b0ed81dcc6abb0f, | ||
1902 | + 0x86ccbb52ea94baea, 0x98e947129fc2b4e9, | ||
1903 | + 0xa87fea27a539e9a5, 0x3f2398d747b36224, | ||
1904 | + 0xd29fe4b18e88640e, 0x8eec7f0d19a03aad, | ||
1905 | + 0x83a3eeeef9153e89, 0x1953cf68300424ac, | ||
1906 | + 0xa48ceaaab75a8e2b, 0x5fa8c3423c052dd7, | ||
1907 | + 0xcdb02555653131b6, 0x3792f412cb06794d, | ||
1908 | + 0x808e17555f3ebf11, 0xe2bbd88bbee40bd0, | ||
1909 | + 0xa0b19d2ab70e6ed6, 0x5b6aceaeae9d0ec4, | ||
1910 | + 0xc8de047564d20a8b, 0xf245825a5a445275, | ||
1911 | + 0xfb158592be068d2e, 0xeed6e2f0f0d56712, | ||
1912 | + 0x9ced737bb6c4183d, 0x55464dd69685606b, | ||
1913 | + 0xc428d05aa4751e4c, 0xaa97e14c3c26b886, | ||
1914 | + 0xf53304714d9265df, 0xd53dd99f4b3066a8, | ||
1915 | + 0x993fe2c6d07b7fab, 0xe546a8038efe4029, | ||
1916 | + 0xbf8fdb78849a5f96, 0xde98520472bdd033, | ||
1917 | + 0xef73d256a5c0f77c, 0x963e66858f6d4440, | ||
1918 | + 0x95a8637627989aad, 0xdde7001379a44aa8, | ||
1919 | + 0xbb127c53b17ec159, 0x5560c018580d5d52, | ||
1920 | + 0xe9d71b689dde71af, 0xaab8f01e6e10b4a6, | ||
1921 | + 0x9226712162ab070d, 0xcab3961304ca70e8, | ||
1922 | + 0xb6b00d69bb55c8d1, 0x3d607b97c5fd0d22, | ||
1923 | + 0xe45c10c42a2b3b05, 0x8cb89a7db77c506a, | ||
1924 | + 0x8eb98a7a9a5b04e3, 0x77f3608e92adb242, | ||
1925 | + 0xb267ed1940f1c61c, 0x55f038b237591ed3, | ||
1926 | + 0xdf01e85f912e37a3, 0x6b6c46dec52f6688, | ||
1927 | + 0x8b61313bbabce2c6, 0x2323ac4b3b3da015, | ||
1928 | + 0xae397d8aa96c1b77, 0xabec975e0a0d081a, | ||
1929 | + 0xd9c7dced53c72255, 0x96e7bd358c904a21, | ||
1930 | + 0x881cea14545c7575, 0x7e50d64177da2e54, | ||
1931 | + 0xaa242499697392d2, 0xdde50bd1d5d0b9e9, | ||
1932 | + 0xd4ad2dbfc3d07787, 0x955e4ec64b44e864, | ||
1933 | + 0x84ec3c97da624ab4, 0xbd5af13bef0b113e, | ||
1934 | + 0xa6274bbdd0fadd61, 0xecb1ad8aeacdd58e, | ||
1935 | + 0xcfb11ead453994ba, 0x67de18eda5814af2, | ||
1936 | + 0x81ceb32c4b43fcf4, 0x80eacf948770ced7, | ||
1937 | + 0xa2425ff75e14fc31, 0xa1258379a94d028d, | ||
1938 | + 0xcad2f7f5359a3b3e, 0x96ee45813a04330, | ||
1939 | + 0xfd87b5f28300ca0d, 0x8bca9d6e188853fc, | ||
1940 | + 0x9e74d1b791e07e48, 0x775ea264cf55347e, | ||
1941 | + 0xc612062576589dda, 0x95364afe032a819e, | ||
1942 | + 0xf79687aed3eec551, 0x3a83ddbd83f52205, | ||
1943 | + 0x9abe14cd44753b52, 0xc4926a9672793543, | ||
1944 | + 0xc16d9a0095928a27, 0x75b7053c0f178294, | ||
1945 | + 0xf1c90080baf72cb1, 0x5324c68b12dd6339, | ||
1946 | + 0x971da05074da7bee, 0xd3f6fc16ebca5e04, | ||
1947 | + 0xbce5086492111aea, 0x88f4bb1ca6bcf585, | ||
1948 | + 0xec1e4a7db69561a5, 0x2b31e9e3d06c32e6, | ||
1949 | + 0x9392ee8e921d5d07, 0x3aff322e62439fd0, | ||
1950 | + 0xb877aa3236a4b449, 0x9befeb9fad487c3, | ||
1951 | + 0xe69594bec44de15b, 0x4c2ebe687989a9b4, | ||
1952 | + 0x901d7cf73ab0acd9, 0xf9d37014bf60a11, | ||
1953 | + 0xb424dc35095cd80f, 0x538484c19ef38c95, | ||
1954 | + 0xe12e13424bb40e13, 0x2865a5f206b06fba, | ||
1955 | + 0x8cbccc096f5088cb, 0xf93f87b7442e45d4, | ||
1956 | + 0xafebff0bcb24aafe, 0xf78f69a51539d749, | ||
1957 | + 0xdbe6fecebdedd5be, 0xb573440e5a884d1c, | ||
1958 | + 0x89705f4136b4a597, 0x31680a88f8953031, | ||
1959 | + 0xabcc77118461cefc, 0xfdc20d2b36ba7c3e, | ||
1960 | + 0xd6bf94d5e57a42bc, 0x3d32907604691b4d, | ||
1961 | + 0x8637bd05af6c69b5, 0xa63f9a49c2c1b110, | ||
1962 | + 0xa7c5ac471b478423, 0xfcf80dc33721d54, | ||
1963 | + 0xd1b71758e219652b, 0xd3c36113404ea4a9, | ||
1964 | + 0x83126e978d4fdf3b, 0x645a1cac083126ea, | ||
1965 | + 0xa3d70a3d70a3d70a, 0x3d70a3d70a3d70a4, | ||
1966 | + 0xcccccccccccccccc, 0xcccccccccccccccd, | ||
1967 | + 0x8000000000000000, 0x0, | ||
1968 | + 0xa000000000000000, 0x0, | ||
1969 | + 0xc800000000000000, 0x0, | ||
1970 | + 0xfa00000000000000, 0x0, | ||
1971 | + 0x9c40000000000000, 0x0, | ||
1972 | + 0xc350000000000000, 0x0, | ||
1973 | + 0xf424000000000000, 0x0, | ||
1974 | + 0x9896800000000000, 0x0, | ||
1975 | + 0xbebc200000000000, 0x0, | ||
1976 | + 0xee6b280000000000, 0x0, | ||
1977 | + 0x9502f90000000000, 0x0, | ||
1978 | + 0xba43b74000000000, 0x0, | ||
1979 | + 0xe8d4a51000000000, 0x0, | ||
1980 | + 0x9184e72a00000000, 0x0, | ||
1981 | + 0xb5e620f480000000, 0x0, | ||
1982 | + 0xe35fa931a0000000, 0x0, | ||
1983 | + 0x8e1bc9bf04000000, 0x0, | ||
1984 | + 0xb1a2bc2ec5000000, 0x0, | ||
1985 | + 0xde0b6b3a76400000, 0x0, | ||
1986 | + 0x8ac7230489e80000, 0x0, | ||
1987 | + 0xad78ebc5ac620000, 0x0, | ||
1988 | + 0xd8d726b7177a8000, 0x0, | ||
1989 | + 0x878678326eac9000, 0x0, | ||
1990 | + 0xa968163f0a57b400, 0x0, | ||
1991 | + 0xd3c21bcecceda100, 0x0, | ||
1992 | + 0x84595161401484a0, 0x0, | ||
1993 | + 0xa56fa5b99019a5c8, 0x0, | ||
1994 | + 0xcecb8f27f4200f3a, 0x0, | ||
1995 | + 0x813f3978f8940984, 0x4000000000000000, | ||
1996 | + 0xa18f07d736b90be5, 0x5000000000000000, | ||
1997 | + 0xc9f2c9cd04674ede, 0xa400000000000000, | ||
1998 | + 0xfc6f7c4045812296, 0x4d00000000000000, | ||
1999 | + 0x9dc5ada82b70b59d, 0xf020000000000000, | ||
2000 | + 0xc5371912364ce305, 0x6c28000000000000, | ||
2001 | + 0xf684df56c3e01bc6, 0xc732000000000000, | ||
2002 | + 0x9a130b963a6c115c, 0x3c7f400000000000, | ||
2003 | + 0xc097ce7bc90715b3, 0x4b9f100000000000, | ||
2004 | + 0xf0bdc21abb48db20, 0x1e86d40000000000, | ||
2005 | + 0x96769950b50d88f4, 0x1314448000000000, | ||
2006 | + 0xbc143fa4e250eb31, 0x17d955a000000000, | ||
2007 | + 0xeb194f8e1ae525fd, 0x5dcfab0800000000, | ||
2008 | + 0x92efd1b8d0cf37be, 0x5aa1cae500000000, | ||
2009 | + 0xb7abc627050305ad, 0xf14a3d9e40000000, | ||
2010 | + 0xe596b7b0c643c719, 0x6d9ccd05d0000000, | ||
2011 | + 0x8f7e32ce7bea5c6f, 0xe4820023a2000000, | ||
2012 | + 0xb35dbf821ae4f38b, 0xdda2802c8a800000, | ||
2013 | + 0xe0352f62a19e306e, 0xd50b2037ad200000, | ||
2014 | + 0x8c213d9da502de45, 0x4526f422cc340000, | ||
2015 | + 0xaf298d050e4395d6, 0x9670b12b7f410000, | ||
2016 | + 0xdaf3f04651d47b4c, 0x3c0cdd765f114000, | ||
2017 | + 0x88d8762bf324cd0f, 0xa5880a69fb6ac800, | ||
2018 | + 0xab0e93b6efee0053, 0x8eea0d047a457a00, | ||
2019 | + 0xd5d238a4abe98068, 0x72a4904598d6d880, | ||
2020 | + 0x85a36366eb71f041, 0x47a6da2b7f864750, | ||
2021 | + 0xa70c3c40a64e6c51, 0x999090b65f67d924, | ||
2022 | + 0xd0cf4b50cfe20765, 0xfff4b4e3f741cf6d, | ||
2023 | + 0x82818f1281ed449f, 0xbff8f10e7a8921a4, | ||
2024 | + 0xa321f2d7226895c7, 0xaff72d52192b6a0d, | ||
2025 | + 0xcbea6f8ceb02bb39, 0x9bf4f8a69f764490, | ||
2026 | + 0xfee50b7025c36a08, 0x2f236d04753d5b4, | ||
2027 | + 0x9f4f2726179a2245, 0x1d762422c946590, | ||
2028 | + 0xc722f0ef9d80aad6, 0x424d3ad2b7b97ef5, | ||
2029 | + 0xf8ebad2b84e0d58b, 0xd2e0898765a7deb2, | ||
2030 | + 0x9b934c3b330c8577, 0x63cc55f49f88eb2f, | ||
2031 | + 0xc2781f49ffcfa6d5, 0x3cbf6b71c76b25fb, | ||
2032 | + 0xf316271c7fc3908a, 0x8bef464e3945ef7a, | ||
2033 | + 0x97edd871cfda3a56, 0x97758bf0e3cbb5ac, | ||
2034 | + 0xbde94e8e43d0c8ec, 0x3d52eeed1cbea317, | ||
2035 | + 0xed63a231d4c4fb27, 0x4ca7aaa863ee4bdd, | ||
2036 | + 0x945e455f24fb1cf8, 0x8fe8caa93e74ef6a, | ||
2037 | + 0xb975d6b6ee39e436, 0xb3e2fd538e122b44, | ||
2038 | + 0xe7d34c64a9c85d44, 0x60dbbca87196b616, | ||
2039 | + 0x90e40fbeea1d3a4a, 0xbc8955e946fe31cd, | ||
2040 | + 0xb51d13aea4a488dd, 0x6babab6398bdbe41, | ||
2041 | + 0xe264589a4dcdab14, 0xc696963c7eed2dd1, | ||
2042 | + 0x8d7eb76070a08aec, 0xfc1e1de5cf543ca2, | ||
2043 | + 0xb0de65388cc8ada8, 0x3b25a55f43294bcb, | ||
2044 | + 0xdd15fe86affad912, 0x49ef0eb713f39ebe, | ||
2045 | + 0x8a2dbf142dfcc7ab, 0x6e3569326c784337, | ||
2046 | + 0xacb92ed9397bf996, 0x49c2c37f07965404, | ||
2047 | + 0xd7e77a8f87daf7fb, 0xdc33745ec97be906, | ||
2048 | + 0x86f0ac99b4e8dafd, 0x69a028bb3ded71a3, | ||
2049 | + 0xa8acd7c0222311bc, 0xc40832ea0d68ce0c, | ||
2050 | + 0xd2d80db02aabd62b, 0xf50a3fa490c30190, | ||
2051 | + 0x83c7088e1aab65db, 0x792667c6da79e0fa, | ||
2052 | + 0xa4b8cab1a1563f52, 0x577001b891185938, | ||
2053 | + 0xcde6fd5e09abcf26, 0xed4c0226b55e6f86, | ||
2054 | + 0x80b05e5ac60b6178, 0x544f8158315b05b4, | ||
2055 | + 0xa0dc75f1778e39d6, 0x696361ae3db1c721, | ||
2056 | + 0xc913936dd571c84c, 0x3bc3a19cd1e38e9, | ||
2057 | + 0xfb5878494ace3a5f, 0x4ab48a04065c723, | ||
2058 | + 0x9d174b2dcec0e47b, 0x62eb0d64283f9c76, | ||
2059 | + 0xc45d1df942711d9a, 0x3ba5d0bd324f8394, | ||
2060 | + 0xf5746577930d6500, 0xca8f44ec7ee36479, | ||
2061 | + 0x9968bf6abbe85f20, 0x7e998b13cf4e1ecb, | ||
2062 | + 0xbfc2ef456ae276e8, 0x9e3fedd8c321a67e, | ||
2063 | + 0xefb3ab16c59b14a2, 0xc5cfe94ef3ea101e, | ||
2064 | + 0x95d04aee3b80ece5, 0xbba1f1d158724a12, | ||
2065 | + 0xbb445da9ca61281f, 0x2a8a6e45ae8edc97, | ||
2066 | + 0xea1575143cf97226, 0xf52d09d71a3293bd, | ||
2067 | + 0x924d692ca61be758, 0x593c2626705f9c56, | ||
2068 | + 0xb6e0c377cfa2e12e, 0x6f8b2fb00c77836c, | ||
2069 | + 0xe498f455c38b997a, 0xb6dfb9c0f956447, | ||
2070 | + 0x8edf98b59a373fec, 0x4724bd4189bd5eac, | ||
2071 | + 0xb2977ee300c50fe7, 0x58edec91ec2cb657, | ||
2072 | + 0xdf3d5e9bc0f653e1, 0x2f2967b66737e3ed, | ||
2073 | + 0x8b865b215899f46c, 0xbd79e0d20082ee74, | ||
2074 | + 0xae67f1e9aec07187, 0xecd8590680a3aa11, | ||
2075 | + 0xda01ee641a708de9, 0xe80e6f4820cc9495, | ||
2076 | + 0x884134fe908658b2, 0x3109058d147fdcdd, | ||
2077 | + 0xaa51823e34a7eede, 0xbd4b46f0599fd415, | ||
2078 | + 0xd4e5e2cdc1d1ea96, 0x6c9e18ac7007c91a, | ||
2079 | + 0x850fadc09923329e, 0x3e2cf6bc604ddb0, | ||
2080 | + 0xa6539930bf6bff45, 0x84db8346b786151c, | ||
2081 | + 0xcfe87f7cef46ff16, 0xe612641865679a63, | ||
2082 | + 0x81f14fae158c5f6e, 0x4fcb7e8f3f60c07e, | ||
2083 | + 0xa26da3999aef7749, 0xe3be5e330f38f09d, | ||
2084 | + 0xcb090c8001ab551c, 0x5cadf5bfd3072cc5, | ||
2085 | + 0xfdcb4fa002162a63, 0x73d9732fc7c8f7f6, | ||
2086 | + 0x9e9f11c4014dda7e, 0x2867e7fddcdd9afa, | ||
2087 | + 0xc646d63501a1511d, 0xb281e1fd541501b8, | ||
2088 | + 0xf7d88bc24209a565, 0x1f225a7ca91a4226, | ||
2089 | + 0x9ae757596946075f, 0x3375788de9b06958, | ||
2090 | + 0xc1a12d2fc3978937, 0x52d6b1641c83ae, | ||
2091 | + 0xf209787bb47d6b84, 0xc0678c5dbd23a49a, | ||
2092 | + 0x9745eb4d50ce6332, 0xf840b7ba963646e0, | ||
2093 | + 0xbd176620a501fbff, 0xb650e5a93bc3d898, | ||
2094 | + 0xec5d3fa8ce427aff, 0xa3e51f138ab4cebe, | ||
2095 | + 0x93ba47c980e98cdf, 0xc66f336c36b10137, | ||
2096 | + 0xb8a8d9bbe123f017, 0xb80b0047445d4184, | ||
2097 | + 0xe6d3102ad96cec1d, 0xa60dc059157491e5, | ||
2098 | + 0x9043ea1ac7e41392, 0x87c89837ad68db2f, | ||
2099 | + 0xb454e4a179dd1877, 0x29babe4598c311fb, | ||
2100 | + 0xe16a1dc9d8545e94, 0xf4296dd6fef3d67a, | ||
2101 | + 0x8ce2529e2734bb1d, 0x1899e4a65f58660c, | ||
2102 | + 0xb01ae745b101e9e4, 0x5ec05dcff72e7f8f, | ||
2103 | + 0xdc21a1171d42645d, 0x76707543f4fa1f73, | ||
2104 | + 0x899504ae72497eba, 0x6a06494a791c53a8, | ||
2105 | + 0xabfa45da0edbde69, 0x487db9d17636892, | ||
2106 | + 0xd6f8d7509292d603, 0x45a9d2845d3c42b6, | ||
2107 | + 0x865b86925b9bc5c2, 0xb8a2392ba45a9b2, | ||
2108 | + 0xa7f26836f282b732, 0x8e6cac7768d7141e, | ||
2109 | + 0xd1ef0244af2364ff, 0x3207d795430cd926, | ||
2110 | + 0x8335616aed761f1f, 0x7f44e6bd49e807b8, | ||
2111 | + 0xa402b9c5a8d3a6e7, 0x5f16206c9c6209a6, | ||
2112 | + 0xcd036837130890a1, 0x36dba887c37a8c0f, | ||
2113 | + 0x802221226be55a64, 0xc2494954da2c9789, | ||
2114 | + 0xa02aa96b06deb0fd, 0xf2db9baa10b7bd6c, | ||
2115 | + 0xc83553c5c8965d3d, 0x6f92829494e5acc7, | ||
2116 | + 0xfa42a8b73abbf48c, 0xcb772339ba1f17f9, | ||
2117 | + 0x9c69a97284b578d7, 0xff2a760414536efb, | ||
2118 | + 0xc38413cf25e2d70d, 0xfef5138519684aba, | ||
2119 | + 0xf46518c2ef5b8cd1, 0x7eb258665fc25d69, | ||
2120 | + 0x98bf2f79d5993802, 0xef2f773ffbd97a61, | ||
2121 | + 0xbeeefb584aff8603, 0xaafb550ffacfd8fa, | ||
2122 | + 0xeeaaba2e5dbf6784, 0x95ba2a53f983cf38, | ||
2123 | + 0x952ab45cfa97a0b2, 0xdd945a747bf26183, | ||
2124 | + 0xba756174393d88df, 0x94f971119aeef9e4, | ||
2125 | + 0xe912b9d1478ceb17, 0x7a37cd5601aab85d, | ||
2126 | + 0x91abb422ccb812ee, 0xac62e055c10ab33a, | ||
2127 | + 0xb616a12b7fe617aa, 0x577b986b314d6009, | ||
2128 | + 0xe39c49765fdf9d94, 0xed5a7e85fda0b80b, | ||
2129 | + 0x8e41ade9fbebc27d, 0x14588f13be847307, | ||
2130 | + 0xb1d219647ae6b31c, 0x596eb2d8ae258fc8, | ||
2131 | + 0xde469fbd99a05fe3, 0x6fca5f8ed9aef3bb, | ||
2132 | + 0x8aec23d680043bee, 0x25de7bb9480d5854, | ||
2133 | + 0xada72ccc20054ae9, 0xaf561aa79a10ae6a, | ||
2134 | + 0xd910f7ff28069da4, 0x1b2ba1518094da04, | ||
2135 | + 0x87aa9aff79042286, 0x90fb44d2f05d0842, | ||
2136 | + 0xa99541bf57452b28, 0x353a1607ac744a53, | ||
2137 | + 0xd3fa922f2d1675f2, 0x42889b8997915ce8, | ||
2138 | + 0x847c9b5d7c2e09b7, 0x69956135febada11, | ||
2139 | + 0xa59bc234db398c25, 0x43fab9837e699095, | ||
2140 | + 0xcf02b2c21207ef2e, 0x94f967e45e03f4bb, | ||
2141 | + 0x8161afb94b44f57d, 0x1d1be0eebac278f5, | ||
2142 | + 0xa1ba1ba79e1632dc, 0x6462d92a69731732, | ||
2143 | + 0xca28a291859bbf93, 0x7d7b8f7503cfdcfe, | ||
2144 | + 0xfcb2cb35e702af78, 0x5cda735244c3d43e, | ||
2145 | + 0x9defbf01b061adab, 0x3a0888136afa64a7, | ||
2146 | + 0xc56baec21c7a1916, 0x88aaa1845b8fdd0, | ||
2147 | + 0xf6c69a72a3989f5b, 0x8aad549e57273d45, | ||
2148 | + 0x9a3c2087a63f6399, 0x36ac54e2f678864b, | ||
2149 | + 0xc0cb28a98fcf3c7f, 0x84576a1bb416a7dd, | ||
2150 | + 0xf0fdf2d3f3c30b9f, 0x656d44a2a11c51d5, | ||
2151 | + 0x969eb7c47859e743, 0x9f644ae5a4b1b325, | ||
2152 | + 0xbc4665b596706114, 0x873d5d9f0dde1fee, | ||
2153 | + 0xeb57ff22fc0c7959, 0xa90cb506d155a7ea, | ||
2154 | + 0x9316ff75dd87cbd8, 0x9a7f12442d588f2, | ||
2155 | + 0xb7dcbf5354e9bece, 0xc11ed6d538aeb2f, | ||
2156 | + 0xe5d3ef282a242e81, 0x8f1668c8a86da5fa, | ||
2157 | + 0x8fa475791a569d10, 0xf96e017d694487bc, | ||
2158 | + 0xb38d92d760ec4455, 0x37c981dcc395a9ac, | ||
2159 | + 0xe070f78d3927556a, 0x85bbe253f47b1417, | ||
2160 | + 0x8c469ab843b89562, 0x93956d7478ccec8e, | ||
2161 | + 0xaf58416654a6babb, 0x387ac8d1970027b2, | ||
2162 | + 0xdb2e51bfe9d0696a, 0x6997b05fcc0319e, | ||
2163 | + 0x88fcf317f22241e2, 0x441fece3bdf81f03, | ||
2164 | + 0xab3c2fddeeaad25a, 0xd527e81cad7626c3, | ||
2165 | + 0xd60b3bd56a5586f1, 0x8a71e223d8d3b074, | ||
2166 | + 0x85c7056562757456, 0xf6872d5667844e49, | ||
2167 | + 0xa738c6bebb12d16c, 0xb428f8ac016561db, | ||
2168 | + 0xd106f86e69d785c7, 0xe13336d701beba52, | ||
2169 | + 0x82a45b450226b39c, 0xecc0024661173473, | ||
2170 | + 0xa34d721642b06084, 0x27f002d7f95d0190, | ||
2171 | + 0xcc20ce9bd35c78a5, 0x31ec038df7b441f4, | ||
2172 | + 0xff290242c83396ce, 0x7e67047175a15271, | ||
2173 | + 0x9f79a169bd203e41, 0xf0062c6e984d386, | ||
2174 | + 0xc75809c42c684dd1, 0x52c07b78a3e60868, | ||
2175 | + 0xf92e0c3537826145, 0xa7709a56ccdf8a82, | ||
2176 | + 0x9bbcc7a142b17ccb, 0x88a66076400bb691, | ||
2177 | + 0xc2abf989935ddbfe, 0x6acff893d00ea435, | ||
2178 | + 0xf356f7ebf83552fe, 0x583f6b8c4124d43, | ||
2179 | + 0x98165af37b2153de, 0xc3727a337a8b704a, | ||
2180 | + 0xbe1bf1b059e9a8d6, 0x744f18c0592e4c5c, | ||
2181 | + 0xeda2ee1c7064130c, 0x1162def06f79df73, | ||
2182 | + 0x9485d4d1c63e8be7, 0x8addcb5645ac2ba8, | ||
2183 | + 0xb9a74a0637ce2ee1, 0x6d953e2bd7173692, | ||
2184 | + 0xe8111c87c5c1ba99, 0xc8fa8db6ccdd0437, | ||
2185 | + 0x910ab1d4db9914a0, 0x1d9c9892400a22a2, | ||
2186 | + 0xb54d5e4a127f59c8, 0x2503beb6d00cab4b, | ||
2187 | + 0xe2a0b5dc971f303a, 0x2e44ae64840fd61d, | ||
2188 | + 0x8da471a9de737e24, 0x5ceaecfed289e5d2, | ||
2189 | + 0xb10d8e1456105dad, 0x7425a83e872c5f47, | ||
2190 | + 0xdd50f1996b947518, 0xd12f124e28f77719, | ||
2191 | + 0x8a5296ffe33cc92f, 0x82bd6b70d99aaa6f, | ||
2192 | + 0xace73cbfdc0bfb7b, 0x636cc64d1001550b, | ||
2193 | + 0xd8210befd30efa5a, 0x3c47f7e05401aa4e, | ||
2194 | + 0x8714a775e3e95c78, 0x65acfaec34810a71, | ||
2195 | + 0xa8d9d1535ce3b396, 0x7f1839a741a14d0d, | ||
2196 | + 0xd31045a8341ca07c, 0x1ede48111209a050, | ||
2197 | + 0x83ea2b892091e44d, 0x934aed0aab460432, | ||
2198 | + 0xa4e4b66b68b65d60, 0xf81da84d5617853f, | ||
2199 | + 0xce1de40642e3f4b9, 0x36251260ab9d668e, | ||
2200 | + 0x80d2ae83e9ce78f3, 0xc1d72b7c6b426019, | ||
2201 | + 0xa1075a24e4421730, 0xb24cf65b8612f81f, | ||
2202 | + 0xc94930ae1d529cfc, 0xdee033f26797b627, | ||
2203 | + 0xfb9b7cd9a4a7443c, 0x169840ef017da3b1, | ||
2204 | + 0x9d412e0806e88aa5, 0x8e1f289560ee864e, | ||
2205 | + 0xc491798a08a2ad4e, 0xf1a6f2bab92a27e2, | ||
2206 | + 0xf5b5d7ec8acb58a2, 0xae10af696774b1db, | ||
2207 | + 0x9991a6f3d6bf1765, 0xacca6da1e0a8ef29, | ||
2208 | + 0xbff610b0cc6edd3f, 0x17fd090a58d32af3, | ||
2209 | + 0xeff394dcff8a948e, 0xddfc4b4cef07f5b0, | ||
2210 | + 0x95f83d0a1fb69cd9, 0x4abdaf101564f98e, | ||
2211 | + 0xbb764c4ca7a4440f, 0x9d6d1ad41abe37f1, | ||
2212 | + 0xea53df5fd18d5513, 0x84c86189216dc5ed, | ||
2213 | + 0x92746b9be2f8552c, 0x32fd3cf5b4e49bb4, | ||
2214 | + 0xb7118682dbb66a77, 0x3fbc8c33221dc2a1, | ||
2215 | + 0xe4d5e82392a40515, 0xfabaf3feaa5334a, | ||
2216 | + 0x8f05b1163ba6832d, 0x29cb4d87f2a7400e, | ||
2217 | + 0xb2c71d5bca9023f8, 0x743e20e9ef511012, | ||
2218 | + 0xdf78e4b2bd342cf6, 0x914da9246b255416, | ||
2219 | + 0x8bab8eefb6409c1a, 0x1ad089b6c2f7548e, | ||
2220 | + 0xae9672aba3d0c320, 0xa184ac2473b529b1, | ||
2221 | + 0xda3c0f568cc4f3e8, 0xc9e5d72d90a2741e, | ||
2222 | + 0x8865899617fb1871, 0x7e2fa67c7a658892, | ||
2223 | + 0xaa7eebfb9df9de8d, 0xddbb901b98feeab7, | ||
2224 | + 0xd51ea6fa85785631, 0x552a74227f3ea565, | ||
2225 | + 0x8533285c936b35de, 0xd53a88958f87275f, | ||
2226 | + 0xa67ff273b8460356, 0x8a892abaf368f137, | ||
2227 | + 0xd01fef10a657842c, 0x2d2b7569b0432d85, | ||
2228 | + 0x8213f56a67f6b29b, 0x9c3b29620e29fc73, | ||
2229 | + 0xa298f2c501f45f42, 0x8349f3ba91b47b8f, | ||
2230 | + 0xcb3f2f7642717713, 0x241c70a936219a73, | ||
2231 | + 0xfe0efb53d30dd4d7, 0xed238cd383aa0110, | ||
2232 | + 0x9ec95d1463e8a506, 0xf4363804324a40aa, | ||
2233 | + 0xc67bb4597ce2ce48, 0xb143c6053edcd0d5, | ||
2234 | + 0xf81aa16fdc1b81da, 0xdd94b7868e94050a, | ||
2235 | + 0x9b10a4e5e9913128, 0xca7cf2b4191c8326, | ||
2236 | + 0xc1d4ce1f63f57d72, 0xfd1c2f611f63a3f0, | ||
2237 | + 0xf24a01a73cf2dccf, 0xbc633b39673c8cec, | ||
2238 | + 0x976e41088617ca01, 0xd5be0503e085d813, | ||
2239 | + 0xbd49d14aa79dbc82, 0x4b2d8644d8a74e18, | ||
2240 | + 0xec9c459d51852ba2, 0xddf8e7d60ed1219e, | ||
2241 | + 0x93e1ab8252f33b45, 0xcabb90e5c942b503, | ||
2242 | + 0xb8da1662e7b00a17, 0x3d6a751f3b936243, | ||
2243 | + 0xe7109bfba19c0c9d, 0xcc512670a783ad4, | ||
2244 | + 0x906a617d450187e2, 0x27fb2b80668b24c5, | ||
2245 | + 0xb484f9dc9641e9da, 0xb1f9f660802dedf6, | ||
2246 | + 0xe1a63853bbd26451, 0x5e7873f8a0396973, | ||
2247 | + 0x8d07e33455637eb2, 0xdb0b487b6423e1e8, | ||
2248 | + 0xb049dc016abc5e5f, 0x91ce1a9a3d2cda62, | ||
2249 | + 0xdc5c5301c56b75f7, 0x7641a140cc7810fb, | ||
2250 | + 0x89b9b3e11b6329ba, 0xa9e904c87fcb0a9d, | ||
2251 | + 0xac2820d9623bf429, 0x546345fa9fbdcd44, | ||
2252 | + 0xd732290fbacaf133, 0xa97c177947ad4095, | ||
2253 | + 0x867f59a9d4bed6c0, 0x49ed8eabcccc485d, | ||
2254 | + 0xa81f301449ee8c70, 0x5c68f256bfff5a74, | ||
2255 | + 0xd226fc195c6a2f8c, 0x73832eec6fff3111, | ||
2256 | + 0x83585d8fd9c25db7, 0xc831fd53c5ff7eab, | ||
2257 | + 0xa42e74f3d032f525, 0xba3e7ca8b77f5e55, | ||
2258 | + 0xcd3a1230c43fb26f, 0x28ce1bd2e55f35eb, | ||
2259 | + 0x80444b5e7aa7cf85, 0x7980d163cf5b81b3, | ||
2260 | + 0xa0555e361951c366, 0xd7e105bcc332621f, | ||
2261 | + 0xc86ab5c39fa63440, 0x8dd9472bf3fefaa7, | ||
2262 | + 0xfa856334878fc150, 0xb14f98f6f0feb951, | ||
2263 | + 0x9c935e00d4b9d8d2, 0x6ed1bf9a569f33d3, | ||
2264 | + 0xc3b8358109e84f07, 0xa862f80ec4700c8, | ||
2265 | + 0xf4a642e14c6262c8, 0xcd27bb612758c0fa, | ||
2266 | + 0x98e7e9cccfbd7dbd, 0x8038d51cb897789c, | ||
2267 | + 0xbf21e44003acdd2c, 0xe0470a63e6bd56c3, | ||
2268 | + 0xeeea5d5004981478, 0x1858ccfce06cac74, | ||
2269 | + 0x95527a5202df0ccb, 0xf37801e0c43ebc8, | ||
2270 | + 0xbaa718e68396cffd, 0xd30560258f54e6ba, | ||
2271 | + 0xe950df20247c83fd, 0x47c6b82ef32a2069, | ||
2272 | + 0x91d28b7416cdd27e, 0x4cdc331d57fa5441, | ||
2273 | + 0xb6472e511c81471d, 0xe0133fe4adf8e952, | ||
2274 | + 0xe3d8f9e563a198e5, 0x58180fddd97723a6, | ||
2275 | + 0x8e679c2f5e44ff8f, 0x570f09eaa7ea7648, | ||
2276 | + }; | ||
2277 | +}; | ||
2278 | + | ||
2279 | +#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE | ||
2280 | + | ||
2281 | +template <class unused> | ||
2282 | +constexpr uint64_t | ||
2283 | + powers_template<unused>::power_of_five_128[number_of_entries]; | ||
2284 | + | ||
2285 | +#endif | ||
2286 | + | ||
2287 | +using powers = powers_template<>; | ||
2288 | + | ||
2289 | +} // namespace fast_float | ||
2290 | + | ||
2291 | +#endif | ||
2292 | + | ||
2293 | +#ifndef FASTFLOAT_DECIMAL_TO_BINARY_H | ||
2294 | +#define FASTFLOAT_DECIMAL_TO_BINARY_H | ||
2295 | + | ||
2296 | +#include <cfloat> | ||
2297 | +#include <cinttypes> | ||
2298 | +#include <cmath> | ||
2299 | +#include <cstdint> | ||
2300 | +#include <cstdlib> | ||
2301 | +#include <cstring> | ||
2302 | + | ||
2303 | +namespace fast_float { | ||
2304 | + | ||
2305 | +// This will compute or rather approximate w * 5**q and return a pair of 64-bit | ||
2306 | +// words approximating the result, with the "high" part corresponding to the | ||
2307 | +// most significant bits and the low part corresponding to the least significant | ||
2308 | +// bits. | ||
2309 | +// | ||
2310 | +template <int bit_precision> | ||
2311 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128 | ||
2312 | +compute_product_approximation(int64_t q, uint64_t w) { | ||
2313 | + const int index = 2 * int(q - powers::smallest_power_of_five); | ||
2314 | + // For small values of q, e.g., q in [0,27], the answer is always exact | ||
2315 | + // because The line value128 firstproduct = full_multiplication(w, | ||
2316 | + // power_of_five_128[index]); gives the exact answer. | ||
2317 | + value128 firstproduct = | ||
2318 | + full_multiplication(w, powers::power_of_five_128[index]); | ||
2319 | + static_assert((bit_precision >= 0) && (bit_precision <= 64), | ||
2320 | + " precision should be in (0,64]"); | ||
2321 | + constexpr uint64_t precision_mask = | ||
2322 | + (bit_precision < 64) ? (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision) | ||
2323 | + : uint64_t(0xFFFFFFFFFFFFFFFF); | ||
2324 | + if ((firstproduct.high & precision_mask) == | ||
2325 | + precision_mask) { // could further guard with (lower + w < lower) | ||
2326 | + // regarding the second product, we only need secondproduct.high, but our | ||
2327 | + // expectation is that the compiler will optimize this extra work away if | ||
2328 | + // needed. | ||
2329 | + value128 secondproduct = | ||
2330 | + full_multiplication(w, powers::power_of_five_128[index + 1]); | ||
2331 | + firstproduct.low += secondproduct.high; | ||
2332 | + if (secondproduct.high > firstproduct.low) { | ||
2333 | + firstproduct.high++; | ||
2334 | + } | ||
2335 | + } | ||
2336 | + return firstproduct; | ||
2337 | +} | ||
2338 | + | ||
2339 | +namespace detail { | ||
2340 | +/** | ||
2341 | + * For q in (0,350), we have that | ||
2342 | + * f = (((152170 + 65536) * q ) >> 16); | ||
2343 | + * is equal to | ||
2344 | + * floor(p) + q | ||
2345 | + * where | ||
2346 | + * p = log(5**q)/log(2) = q * log(5)/log(2) | ||
2347 | + * | ||
2348 | + * For negative values of q in (-400,0), we have that | ||
2349 | + * f = (((152170 + 65536) * q ) >> 16); | ||
2350 | + * is equal to | ||
2351 | + * -ceil(p) + q | ||
2352 | + * where | ||
2353 | + * p = log(5**-q)/log(2) = -q * log(5)/log(2) | ||
2354 | + */ | ||
2355 | +constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept { | ||
2356 | + return (((152170 + 65536) * q) >> 16) + 63; | ||
2357 | +} | ||
2358 | +} // namespace detail | ||
2359 | + | ||
2360 | +// create an adjusted mantissa, biased by the invalid power2 | ||
2361 | +// for significant digits already multiplied by 10 ** q. | ||
2362 | +template <typename binary> | ||
2363 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 adjusted_mantissa | ||
2364 | +compute_error_scaled(int64_t q, uint64_t w, int lz) noexcept { | ||
2365 | + int hilz = int(w >> 63) ^ 1; | ||
2366 | + adjusted_mantissa answer; | ||
2367 | + answer.mantissa = w << hilz; | ||
2368 | + int bias = binary::mantissa_explicit_bits() - binary::minimum_exponent(); | ||
2369 | + answer.power2 = int32_t(detail::power(int32_t(q)) + bias - hilz - lz - 62 + | ||
2370 | + invalid_am_bias); | ||
2371 | + return answer; | ||
2372 | +} | ||
2373 | + | ||
2374 | +// w * 10 ** q, without rounding the representation up. | ||
2375 | +// the power2 in the exponent will be adjusted by invalid_am_bias. | ||
2376 | +template <typename binary> | ||
2377 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa | ||
2378 | +compute_error(int64_t q, uint64_t w) noexcept { | ||
2379 | + int lz = leading_zeroes(w); | ||
2380 | + w <<= lz; | ||
2381 | + value128 product = | ||
2382 | + compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w); | ||
2383 | + return compute_error_scaled<binary>(q, product.high, lz); | ||
2384 | +} | ||
2385 | + | ||
2386 | +// w * 10 ** q | ||
2387 | +// The returned value should be a valid ieee64 number that simply need to be | ||
2388 | +// packed. However, in some very rare cases, the computation will fail. In such | ||
2389 | +// cases, we return an adjusted_mantissa with a negative power of 2: the caller | ||
2390 | +// should recompute in such cases. | ||
2391 | +template <typename binary> | ||
2392 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa | ||
2393 | +compute_float(int64_t q, uint64_t w) noexcept { | ||
2394 | + adjusted_mantissa answer; | ||
2395 | + if ((w == 0) || (q < binary::smallest_power_of_ten())) { | ||
2396 | + answer.power2 = 0; | ||
2397 | + answer.mantissa = 0; | ||
2398 | + // result should be zero | ||
2399 | + return answer; | ||
2400 | + } | ||
2401 | + if (q > binary::largest_power_of_ten()) { | ||
2402 | + // we want to get infinity: | ||
2403 | + answer.power2 = binary::infinite_power(); | ||
2404 | + answer.mantissa = 0; | ||
2405 | + return answer; | ||
2406 | + } | ||
2407 | + // At this point in time q is in [powers::smallest_power_of_five, | ||
2408 | + // powers::largest_power_of_five]. | ||
2409 | + | ||
2410 | + // We want the most significant bit of i to be 1. Shift if needed. | ||
2411 | + int lz = leading_zeroes(w); | ||
2412 | + w <<= lz; | ||
2413 | + | ||
2414 | + // The required precision is binary::mantissa_explicit_bits() + 3 because | ||
2415 | + // 1. We need the implicit bit | ||
2416 | + // 2. We need an extra bit for rounding purposes | ||
2417 | + // 3. We might lose a bit due to the "upperbit" routine (result too small, | ||
2418 | + // requiring a shift) | ||
2419 | + | ||
2420 | + value128 product = | ||
2421 | + compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w); | ||
2422 | + // The computed 'product' is always sufficient. | ||
2423 | + // Mathematical proof: | ||
2424 | + // Noble Mushtak and Daniel Lemire, Fast Number Parsing Without Fallback (to | ||
2425 | + // appear) See script/mushtak_lemire.py | ||
2426 | + | ||
2427 | + // The "compute_product_approximation" function can be slightly slower than a | ||
2428 | + // branchless approach: value128 product = compute_product(q, w); but in | ||
2429 | + // practice, we can win big with the compute_product_approximation if its | ||
2430 | + // additional branch is easily predicted. Which is best is data specific. | ||
2431 | + int upperbit = int(product.high >> 63); | ||
2432 | + int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3; | ||
2433 | + | ||
2434 | + answer.mantissa = product.high >> shift; | ||
2435 | + | ||
2436 | + answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz - | ||
2437 | + binary::minimum_exponent()); | ||
2438 | + if (answer.power2 <= 0) { // we have a subnormal? | ||
2439 | + // Here have that answer.power2 <= 0 so -answer.power2 >= 0 | ||
2440 | + if (-answer.power2 + 1 >= | ||
2441 | + 64) { // if we have more than 64 bits below the minimum exponent, you | ||
2442 | + // have a zero for sure. | ||
2443 | + answer.power2 = 0; | ||
2444 | + answer.mantissa = 0; | ||
2445 | + // result should be zero | ||
2446 | + return answer; | ||
2447 | + } | ||
2448 | + // next line is safe because -answer.power2 + 1 < 64 | ||
2449 | + answer.mantissa >>= -answer.power2 + 1; | ||
2450 | + // Thankfully, we can't have both "round-to-even" and subnormals because | ||
2451 | + // "round-to-even" only occurs for powers close to 0. | ||
2452 | + answer.mantissa += (answer.mantissa & 1); // round up | ||
2453 | + answer.mantissa >>= 1; | ||
2454 | + // There is a weird scenario where we don't have a subnormal but just. | ||
2455 | + // Suppose we start with 2.2250738585072013e-308, we end up | ||
2456 | + // with 0x3fffffffffffff x 2^-1023-53 which is technically subnormal | ||
2457 | + // whereas 0x40000000000000 x 2^-1023-53 is normal. Now, we need to round | ||
2458 | + // up 0x3fffffffffffff x 2^-1023-53 and once we do, we are no longer | ||
2459 | + // subnormal, but we can only know this after rounding. | ||
2460 | + // So we only declare a subnormal if we are smaller than the threshold. | ||
2461 | + answer.power2 = | ||
2462 | + (answer.mantissa < (uint64_t(1) << binary::mantissa_explicit_bits())) | ||
2463 | + ? 0 | ||
2464 | + : 1; | ||
2465 | + return answer; | ||
2466 | + } | ||
2467 | + | ||
2468 | + // usually, we round *up*, but if we fall right in between and and we have an | ||
2469 | + // even basis, we need to round down | ||
2470 | + // We are only concerned with the cases where 5**q fits in single 64-bit word. | ||
2471 | + if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) && | ||
2472 | + (q <= binary::max_exponent_round_to_even()) && | ||
2473 | + ((answer.mantissa & 3) == 1)) { // we may fall between two floats! | ||
2474 | + // To be in-between two floats we need that in doing | ||
2475 | + // answer.mantissa = product.high >> (upperbit + 64 - | ||
2476 | + // binary::mantissa_explicit_bits() - 3); | ||
2477 | + // ... we dropped out only zeroes. But if this happened, then we can go | ||
2478 | + // back!!! | ||
2479 | + if ((answer.mantissa << shift) == product.high) { | ||
2480 | + answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up | ||
2481 | + } | ||
2482 | + } | ||
2483 | + | ||
2484 | + answer.mantissa += (answer.mantissa & 1); // round up | ||
2485 | + answer.mantissa >>= 1; | ||
2486 | + if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) { | ||
2487 | + answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits()); | ||
2488 | + answer.power2++; // undo previous addition | ||
2489 | + } | ||
2490 | + | ||
2491 | + answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits()); | ||
2492 | + if (answer.power2 >= binary::infinite_power()) { // infinity | ||
2493 | + answer.power2 = binary::infinite_power(); | ||
2494 | + answer.mantissa = 0; | ||
2495 | + } | ||
2496 | + return answer; | ||
2497 | +} | ||
2498 | + | ||
2499 | +} // namespace fast_float | ||
2500 | + | ||
2501 | +#endif | ||
2502 | + | ||
2503 | +#ifndef FASTFLOAT_BIGINT_H | ||
2504 | +#define FASTFLOAT_BIGINT_H | ||
2505 | + | ||
2506 | +#include <algorithm> | ||
2507 | +#include <cstdint> | ||
2508 | +#include <climits> | ||
2509 | +#include <cstring> | ||
2510 | + | ||
2511 | + | ||
2512 | +namespace fast_float { | ||
2513 | + | ||
2514 | +// the limb width: we want efficient multiplication of double the bits in | ||
2515 | +// limb, or for 64-bit limbs, at least 64-bit multiplication where we can | ||
2516 | +// extract the high and low parts efficiently. this is every 64-bit | ||
2517 | +// architecture except for sparc, which emulates 128-bit multiplication. | ||
2518 | +// we might have platforms where `CHAR_BIT` is not 8, so let's avoid | ||
2519 | +// doing `8 * sizeof(limb)`. | ||
2520 | +#if defined(FASTFLOAT_64BIT) && !defined(__sparc) | ||
2521 | +#define FASTFLOAT_64BIT_LIMB 1 | ||
2522 | +typedef uint64_t limb; | ||
2523 | +constexpr size_t limb_bits = 64; | ||
2524 | +#else | ||
2525 | +#define FASTFLOAT_32BIT_LIMB | ||
2526 | +typedef uint32_t limb; | ||
2527 | +constexpr size_t limb_bits = 32; | ||
2528 | +#endif | ||
2529 | + | ||
2530 | +typedef span<limb> limb_span; | ||
2531 | + | ||
2532 | +// number of bits in a bigint. this needs to be at least the number | ||
2533 | +// of bits required to store the largest bigint, which is | ||
2534 | +// `log2(10**(digits + max_exp))`, or `log2(10**(767 + 342))`, or | ||
2535 | +// ~3600 bits, so we round to 4000. | ||
2536 | +constexpr size_t bigint_bits = 4000; | ||
2537 | +constexpr size_t bigint_limbs = bigint_bits / limb_bits; | ||
2538 | + | ||
2539 | +// vector-like type that is allocated on the stack. the entire | ||
2540 | +// buffer is pre-allocated, and only the length changes. | ||
2541 | +template <uint16_t size> struct stackvec { | ||
2542 | + limb data[size]; | ||
2543 | + // we never need more than 150 limbs | ||
2544 | + uint16_t length{0}; | ||
2545 | + | ||
2546 | + stackvec() = default; | ||
2547 | + stackvec(const stackvec &) = delete; | ||
2548 | + stackvec &operator=(const stackvec &) = delete; | ||
2549 | + stackvec(stackvec &&) = delete; | ||
2550 | + stackvec &operator=(stackvec &&other) = delete; | ||
2551 | + | ||
2552 | + // create stack vector from existing limb span. | ||
2553 | + FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) { | ||
2554 | + FASTFLOAT_ASSERT(try_extend(s)); | ||
2555 | + } | ||
2556 | + | ||
2557 | + FASTFLOAT_CONSTEXPR14 limb &operator[](size_t index) noexcept { | ||
2558 | + FASTFLOAT_DEBUG_ASSERT(index < length); | ||
2559 | + return data[index]; | ||
2560 | + } | ||
2561 | + FASTFLOAT_CONSTEXPR14 const limb &operator[](size_t index) const noexcept { | ||
2562 | + FASTFLOAT_DEBUG_ASSERT(index < length); | ||
2563 | + return data[index]; | ||
2564 | + } | ||
2565 | + // index from the end of the container | ||
2566 | + FASTFLOAT_CONSTEXPR14 const limb &rindex(size_t index) const noexcept { | ||
2567 | + FASTFLOAT_DEBUG_ASSERT(index < length); | ||
2568 | + size_t rindex = length - index - 1; | ||
2569 | + return data[rindex]; | ||
2570 | + } | ||
2571 | + | ||
2572 | + // set the length, without bounds checking. | ||
2573 | + FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept { | ||
2574 | + length = uint16_t(len); | ||
2575 | + } | ||
2576 | + constexpr size_t len() const noexcept { return length; } | ||
2577 | + constexpr bool is_empty() const noexcept { return length == 0; } | ||
2578 | + constexpr size_t capacity() const noexcept { return size; } | ||
2579 | + // append item to vector, without bounds checking | ||
2580 | + FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept { | ||
2581 | + data[length] = value; | ||
2582 | + length++; | ||
2583 | + } | ||
2584 | + // append item to vector, returning if item was added | ||
2585 | + FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept { | ||
2586 | + if (len() < capacity()) { | ||
2587 | + push_unchecked(value); | ||
2588 | + return true; | ||
2589 | + } else { | ||
2590 | + return false; | ||
2591 | + } | ||
2592 | + } | ||
2593 | + // add items to the vector, from a span, without bounds checking | ||
2594 | + FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept { | ||
2595 | + limb *ptr = data + length; | ||
2596 | + std::copy_n(s.ptr, s.len(), ptr); | ||
2597 | + set_len(len() + s.len()); | ||
2598 | + } | ||
2599 | + // try to add items to the vector, returning if items were added | ||
2600 | + FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept { | ||
2601 | + if (len() + s.len() <= capacity()) { | ||
2602 | + extend_unchecked(s); | ||
2603 | + return true; | ||
2604 | + } else { | ||
2605 | + return false; | ||
2606 | + } | ||
2607 | + } | ||
2608 | + // resize the vector, without bounds checking | ||
2609 | + // if the new size is longer than the vector, assign value to each | ||
2610 | + // appended item. | ||
2611 | + FASTFLOAT_CONSTEXPR20 | ||
2612 | + void resize_unchecked(size_t new_len, limb value) noexcept { | ||
2613 | + if (new_len > len()) { | ||
2614 | + size_t count = new_len - len(); | ||
2615 | + limb *first = data + len(); | ||
2616 | + limb *last = first + count; | ||
2617 | + ::std::fill(first, last, value); | ||
2618 | + set_len(new_len); | ||
2619 | + } else { | ||
2620 | + set_len(new_len); | ||
2621 | + } | ||
2622 | + } | ||
2623 | + // try to resize the vector, returning if the vector was resized. | ||
2624 | + FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept { | ||
2625 | + if (new_len > capacity()) { | ||
2626 | + return false; | ||
2627 | + } else { | ||
2628 | + resize_unchecked(new_len, value); | ||
2629 | + return true; | ||
2630 | + } | ||
2631 | + } | ||
2632 | + // check if any limbs are non-zero after the given index. | ||
2633 | + // this needs to be done in reverse order, since the index | ||
2634 | + // is relative to the most significant limbs. | ||
2635 | + FASTFLOAT_CONSTEXPR14 bool nonzero(size_t index) const noexcept { | ||
2636 | + while (index < len()) { | ||
2637 | + if (rindex(index) != 0) { | ||
2638 | + return true; | ||
2639 | + } | ||
2640 | + index++; | ||
2641 | + } | ||
2642 | + return false; | ||
2643 | + } | ||
2644 | + // normalize the big integer, so most-significant zero limbs are removed. | ||
2645 | + FASTFLOAT_CONSTEXPR14 void normalize() noexcept { | ||
2646 | + while (len() > 0 && rindex(0) == 0) { | ||
2647 | + length--; | ||
2648 | + } | ||
2649 | + } | ||
2650 | +}; | ||
2651 | + | ||
2652 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t | ||
2653 | +empty_hi64(bool &truncated) noexcept { | ||
2654 | + truncated = false; | ||
2655 | + return 0; | ||
2656 | +} | ||
2657 | + | ||
2658 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t | ||
2659 | +uint64_hi64(uint64_t r0, bool &truncated) noexcept { | ||
2660 | + truncated = false; | ||
2661 | + int shl = leading_zeroes(r0); | ||
2662 | + return r0 << shl; | ||
2663 | +} | ||
2664 | + | ||
2665 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t | ||
2666 | +uint64_hi64(uint64_t r0, uint64_t r1, bool &truncated) noexcept { | ||
2667 | + int shl = leading_zeroes(r0); | ||
2668 | + if (shl == 0) { | ||
2669 | + truncated = r1 != 0; | ||
2670 | + return r0; | ||
2671 | + } else { | ||
2672 | + int shr = 64 - shl; | ||
2673 | + truncated = (r1 << shl) != 0; | ||
2674 | + return (r0 << shl) | (r1 >> shr); | ||
2675 | + } | ||
2676 | +} | ||
2677 | + | ||
2678 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t | ||
2679 | +uint32_hi64(uint32_t r0, bool &truncated) noexcept { | ||
2680 | + return uint64_hi64(r0, truncated); | ||
2681 | +} | ||
2682 | + | ||
2683 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t | ||
2684 | +uint32_hi64(uint32_t r0, uint32_t r1, bool &truncated) noexcept { | ||
2685 | + uint64_t x0 = r0; | ||
2686 | + uint64_t x1 = r1; | ||
2687 | + return uint64_hi64((x0 << 32) | x1, truncated); | ||
2688 | +} | ||
2689 | + | ||
2690 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 uint64_t | ||
2691 | +uint32_hi64(uint32_t r0, uint32_t r1, uint32_t r2, bool &truncated) noexcept { | ||
2692 | + uint64_t x0 = r0; | ||
2693 | + uint64_t x1 = r1; | ||
2694 | + uint64_t x2 = r2; | ||
2695 | + return uint64_hi64(x0, (x1 << 32) | x2, truncated); | ||
2696 | +} | ||
2697 | + | ||
2698 | +// add two small integers, checking for overflow. | ||
2699 | +// we want an efficient operation. for msvc, where | ||
2700 | +// we don't have built-in intrinsics, this is still | ||
2701 | +// pretty fast. | ||
2702 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb | ||
2703 | +scalar_add(limb x, limb y, bool &overflow) noexcept { | ||
2704 | + limb z; | ||
2705 | +// gcc and clang | ||
2706 | +#if defined(__has_builtin) | ||
2707 | +#if __has_builtin(__builtin_add_overflow) | ||
2708 | + if (!cpp20_and_in_constexpr()) { | ||
2709 | + overflow = __builtin_add_overflow(x, y, &z); | ||
2710 | + return z; | ||
2711 | + } | ||
2712 | +#endif | ||
2713 | +#endif | ||
2714 | + | ||
2715 | + // generic, this still optimizes correctly on MSVC. | ||
2716 | + z = x + y; | ||
2717 | + overflow = z < x; | ||
2718 | + return z; | ||
2719 | +} | ||
2720 | + | ||
2721 | +// multiply two small integers, getting both the high and low bits. | ||
2722 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 limb | ||
2723 | +scalar_mul(limb x, limb y, limb &carry) noexcept { | ||
2724 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
2725 | +#if defined(__SIZEOF_INT128__) | ||
2726 | + // GCC and clang both define it as an extension. | ||
2727 | + __uint128_t z = __uint128_t(x) * __uint128_t(y) + __uint128_t(carry); | ||
2728 | + carry = limb(z >> limb_bits); | ||
2729 | + return limb(z); | ||
2730 | +#else | ||
2731 | + // fallback, no native 128-bit integer multiplication with carry. | ||
2732 | + // on msvc, this optimizes identically, somehow. | ||
2733 | + value128 z = full_multiplication(x, y); | ||
2734 | + bool overflow; | ||
2735 | + z.low = scalar_add(z.low, carry, overflow); | ||
2736 | + z.high += uint64_t(overflow); // cannot overflow | ||
2737 | + carry = z.high; | ||
2738 | + return z.low; | ||
2739 | +#endif | ||
2740 | +#else | ||
2741 | + uint64_t z = uint64_t(x) * uint64_t(y) + uint64_t(carry); | ||
2742 | + carry = limb(z >> limb_bits); | ||
2743 | + return limb(z); | ||
2744 | +#endif | ||
2745 | +} | ||
2746 | + | ||
2747 | +// add scalar value to bigint starting from offset. | ||
2748 | +// used in grade school multiplication | ||
2749 | +template <uint16_t size> | ||
2750 | +inline FASTFLOAT_CONSTEXPR20 bool small_add_from(stackvec<size> &vec, limb y, | ||
2751 | + size_t start) noexcept { | ||
2752 | + size_t index = start; | ||
2753 | + limb carry = y; | ||
2754 | + bool overflow; | ||
2755 | + while (carry != 0 && index < vec.len()) { | ||
2756 | + vec[index] = scalar_add(vec[index], carry, overflow); | ||
2757 | + carry = limb(overflow); | ||
2758 | + index += 1; | ||
2759 | + } | ||
2760 | + if (carry != 0) { | ||
2761 | + FASTFLOAT_TRY(vec.try_push(carry)); | ||
2762 | + } | ||
2763 | + return true; | ||
2764 | +} | ||
2765 | + | ||
2766 | +// add scalar value to bigint. | ||
2767 | +template <uint16_t size> | ||
2768 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool | ||
2769 | +small_add(stackvec<size> &vec, limb y) noexcept { | ||
2770 | + return small_add_from(vec, y, 0); | ||
2771 | +} | ||
2772 | + | ||
2773 | +// multiply bigint by scalar value. | ||
2774 | +template <uint16_t size> | ||
2775 | +inline FASTFLOAT_CONSTEXPR20 bool small_mul(stackvec<size> &vec, | ||
2776 | + limb y) noexcept { | ||
2777 | + limb carry = 0; | ||
2778 | + for (size_t index = 0; index < vec.len(); index++) { | ||
2779 | + vec[index] = scalar_mul(vec[index], y, carry); | ||
2780 | + } | ||
2781 | + if (carry != 0) { | ||
2782 | + FASTFLOAT_TRY(vec.try_push(carry)); | ||
2783 | + } | ||
2784 | + return true; | ||
2785 | +} | ||
2786 | + | ||
2787 | +// add bigint to bigint starting from index. | ||
2788 | +// used in grade school multiplication | ||
2789 | +template <uint16_t size> | ||
2790 | +FASTFLOAT_CONSTEXPR20 bool large_add_from(stackvec<size> &x, limb_span y, | ||
2791 | + size_t start) noexcept { | ||
2792 | + // the effective x buffer is from `xstart..x.len()`, so exit early | ||
2793 | + // if we can't get that current range. | ||
2794 | + if (x.len() < start || y.len() > x.len() - start) { | ||
2795 | + FASTFLOAT_TRY(x.try_resize(y.len() + start, 0)); | ||
2796 | + } | ||
2797 | + | ||
2798 | + bool carry = false; | ||
2799 | + for (size_t index = 0; index < y.len(); index++) { | ||
2800 | + limb xi = x[index + start]; | ||
2801 | + limb yi = y[index]; | ||
2802 | + bool c1 = false; | ||
2803 | + bool c2 = false; | ||
2804 | + xi = scalar_add(xi, yi, c1); | ||
2805 | + if (carry) { | ||
2806 | + xi = scalar_add(xi, 1, c2); | ||
2807 | + } | ||
2808 | + x[index + start] = xi; | ||
2809 | + carry = c1 | c2; | ||
2810 | + } | ||
2811 | + | ||
2812 | + // handle overflow | ||
2813 | + if (carry) { | ||
2814 | + FASTFLOAT_TRY(small_add_from(x, 1, y.len() + start)); | ||
2815 | + } | ||
2816 | + return true; | ||
2817 | +} | ||
2818 | + | ||
2819 | +// add bigint to bigint. | ||
2820 | +template <uint16_t size> | ||
2821 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool | ||
2822 | +large_add_from(stackvec<size> &x, limb_span y) noexcept { | ||
2823 | + return large_add_from(x, y, 0); | ||
2824 | +} | ||
2825 | + | ||
2826 | +// grade-school multiplication algorithm | ||
2827 | +template <uint16_t size> | ||
2828 | +FASTFLOAT_CONSTEXPR20 bool long_mul(stackvec<size> &x, limb_span y) noexcept { | ||
2829 | + limb_span xs = limb_span(x.data, x.len()); | ||
2830 | + stackvec<size> z(xs); | ||
2831 | + limb_span zs = limb_span(z.data, z.len()); | ||
2832 | + | ||
2833 | + if (y.len() != 0) { | ||
2834 | + limb y0 = y[0]; | ||
2835 | + FASTFLOAT_TRY(small_mul(x, y0)); | ||
2836 | + for (size_t index = 1; index < y.len(); index++) { | ||
2837 | + limb yi = y[index]; | ||
2838 | + stackvec<size> zi; | ||
2839 | + if (yi != 0) { | ||
2840 | + // re-use the same buffer throughout | ||
2841 | + zi.set_len(0); | ||
2842 | + FASTFLOAT_TRY(zi.try_extend(zs)); | ||
2843 | + FASTFLOAT_TRY(small_mul(zi, yi)); | ||
2844 | + limb_span zis = limb_span(zi.data, zi.len()); | ||
2845 | + FASTFLOAT_TRY(large_add_from(x, zis, index)); | ||
2846 | + } | ||
2847 | + } | ||
2848 | + } | ||
2849 | + | ||
2850 | + x.normalize(); | ||
2851 | + return true; | ||
2852 | +} | ||
2853 | + | ||
2854 | +// grade-school multiplication algorithm | ||
2855 | +template <uint16_t size> | ||
2856 | +FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept { | ||
2857 | + if (y.len() == 1) { | ||
2858 | + FASTFLOAT_TRY(small_mul(x, y[0])); | ||
2859 | + } else { | ||
2860 | + FASTFLOAT_TRY(long_mul(x, y)); | ||
2861 | + } | ||
2862 | + return true; | ||
2863 | +} | ||
2864 | + | ||
2865 | +template <typename = void> struct pow5_tables { | ||
2866 | + static constexpr uint32_t large_step = 135; | ||
2867 | + static constexpr uint64_t small_power_of_5[] = { | ||
2868 | + 1UL, | ||
2869 | + 5UL, | ||
2870 | + 25UL, | ||
2871 | + 125UL, | ||
2872 | + 625UL, | ||
2873 | + 3125UL, | ||
2874 | + 15625UL, | ||
2875 | + 78125UL, | ||
2876 | + 390625UL, | ||
2877 | + 1953125UL, | ||
2878 | + 9765625UL, | ||
2879 | + 48828125UL, | ||
2880 | + 244140625UL, | ||
2881 | + 1220703125UL, | ||
2882 | + 6103515625UL, | ||
2883 | + 30517578125UL, | ||
2884 | + 152587890625UL, | ||
2885 | + 762939453125UL, | ||
2886 | + 3814697265625UL, | ||
2887 | + 19073486328125UL, | ||
2888 | + 95367431640625UL, | ||
2889 | + 476837158203125UL, | ||
2890 | + 2384185791015625UL, | ||
2891 | + 11920928955078125UL, | ||
2892 | + 59604644775390625UL, | ||
2893 | + 298023223876953125UL, | ||
2894 | + 1490116119384765625UL, | ||
2895 | + 7450580596923828125UL, | ||
2896 | + }; | ||
2897 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
2898 | + constexpr static limb large_power_of_5[] = { | ||
2899 | + 1414648277510068013UL, 9180637584431281687UL, 4539964771860779200UL, | ||
2900 | + 10482974169319127550UL, 198276706040285095UL}; | ||
2901 | +#else | ||
2902 | + constexpr static limb large_power_of_5[] = { | ||
2903 | + 4279965485U, 329373468U, 4020270615U, 2137533757U, 4287402176U, | ||
2904 | + 1057042919U, 1071430142U, 2440757623U, 381945767U, 46164893U}; | ||
2905 | +#endif | ||
2906 | +}; | ||
2907 | + | ||
2908 | +#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE | ||
2909 | + | ||
2910 | +template <typename T> constexpr uint32_t pow5_tables<T>::large_step; | ||
2911 | + | ||
2912 | +template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[]; | ||
2913 | + | ||
2914 | +template <typename T> constexpr limb pow5_tables<T>::large_power_of_5[]; | ||
2915 | + | ||
2916 | +#endif | ||
2917 | + | ||
2918 | +// big integer type. implements a small subset of big integer | ||
2919 | +// arithmetic, using simple algorithms since asymptotically | ||
2920 | +// faster algorithms are slower for a small number of limbs. | ||
2921 | +// all operations assume the big-integer is normalized. | ||
2922 | +struct bigint : pow5_tables<> { | ||
2923 | + // storage of the limbs, in little-endian order. | ||
2924 | + stackvec<bigint_limbs> vec; | ||
2925 | + | ||
2926 | + FASTFLOAT_CONSTEXPR20 bigint() : vec() {} | ||
2927 | + bigint(const bigint &) = delete; | ||
2928 | + bigint &operator=(const bigint &) = delete; | ||
2929 | + bigint(bigint &&) = delete; | ||
2930 | + bigint &operator=(bigint &&other) = delete; | ||
2931 | + | ||
2932 | + FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() { | ||
2933 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
2934 | + vec.push_unchecked(value); | ||
2935 | +#else | ||
2936 | + vec.push_unchecked(uint32_t(value)); | ||
2937 | + vec.push_unchecked(uint32_t(value >> 32)); | ||
2938 | +#endif | ||
2939 | + vec.normalize(); | ||
2940 | + } | ||
2941 | + | ||
2942 | + // get the high 64 bits from the vector, and if bits were truncated. | ||
2943 | + // this is to get the significant digits for the float. | ||
2944 | + FASTFLOAT_CONSTEXPR20 uint64_t hi64(bool &truncated) const noexcept { | ||
2945 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
2946 | + if (vec.len() == 0) { | ||
2947 | + return empty_hi64(truncated); | ||
2948 | + } else if (vec.len() == 1) { | ||
2949 | + return uint64_hi64(vec.rindex(0), truncated); | ||
2950 | + } else { | ||
2951 | + uint64_t result = uint64_hi64(vec.rindex(0), vec.rindex(1), truncated); | ||
2952 | + truncated |= vec.nonzero(2); | ||
2953 | + return result; | ||
2954 | + } | ||
2955 | +#else | ||
2956 | + if (vec.len() == 0) { | ||
2957 | + return empty_hi64(truncated); | ||
2958 | + } else if (vec.len() == 1) { | ||
2959 | + return uint32_hi64(vec.rindex(0), truncated); | ||
2960 | + } else if (vec.len() == 2) { | ||
2961 | + return uint32_hi64(vec.rindex(0), vec.rindex(1), truncated); | ||
2962 | + } else { | ||
2963 | + uint64_t result = | ||
2964 | + uint32_hi64(vec.rindex(0), vec.rindex(1), vec.rindex(2), truncated); | ||
2965 | + truncated |= vec.nonzero(3); | ||
2966 | + return result; | ||
2967 | + } | ||
2968 | +#endif | ||
2969 | + } | ||
2970 | + | ||
2971 | + // compare two big integers, returning the large value. | ||
2972 | + // assumes both are normalized. if the return value is | ||
2973 | + // negative, other is larger, if the return value is | ||
2974 | + // positive, this is larger, otherwise they are equal. | ||
2975 | + // the limbs are stored in little-endian order, so we | ||
2976 | + // must compare the limbs in ever order. | ||
2977 | + FASTFLOAT_CONSTEXPR20 int compare(const bigint &other) const noexcept { | ||
2978 | + if (vec.len() > other.vec.len()) { | ||
2979 | + return 1; | ||
2980 | + } else if (vec.len() < other.vec.len()) { | ||
2981 | + return -1; | ||
2982 | + } else { | ||
2983 | + for (size_t index = vec.len(); index > 0; index--) { | ||
2984 | + limb xi = vec[index - 1]; | ||
2985 | + limb yi = other.vec[index - 1]; | ||
2986 | + if (xi > yi) { | ||
2987 | + return 1; | ||
2988 | + } else if (xi < yi) { | ||
2989 | + return -1; | ||
2990 | + } | ||
2991 | + } | ||
2992 | + return 0; | ||
2993 | + } | ||
2994 | + } | ||
2995 | + | ||
2996 | + // shift left each limb n bits, carrying over to the new limb | ||
2997 | + // returns true if we were able to shift all the digits. | ||
2998 | + FASTFLOAT_CONSTEXPR20 bool shl_bits(size_t n) noexcept { | ||
2999 | + // Internally, for each item, we shift left by n, and add the previous | ||
3000 | + // right shifted limb-bits. | ||
3001 | + // For example, we transform (for u8) shifted left 2, to: | ||
3002 | + // b10100100 b01000010 | ||
3003 | + // b10 b10010001 b00001000 | ||
3004 | + FASTFLOAT_DEBUG_ASSERT(n != 0); | ||
3005 | + FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8); | ||
3006 | + | ||
3007 | + size_t shl = n; | ||
3008 | + size_t shr = limb_bits - shl; | ||
3009 | + limb prev = 0; | ||
3010 | + for (size_t index = 0; index < vec.len(); index++) { | ||
3011 | + limb xi = vec[index]; | ||
3012 | + vec[index] = (xi << shl) | (prev >> shr); | ||
3013 | + prev = xi; | ||
3014 | + } | ||
3015 | + | ||
3016 | + limb carry = prev >> shr; | ||
3017 | + if (carry != 0) { | ||
3018 | + return vec.try_push(carry); | ||
3019 | + } | ||
3020 | + return true; | ||
3021 | + } | ||
3022 | + | ||
3023 | + // move the limbs left by `n` limbs. | ||
3024 | + FASTFLOAT_CONSTEXPR20 bool shl_limbs(size_t n) noexcept { | ||
3025 | + FASTFLOAT_DEBUG_ASSERT(n != 0); | ||
3026 | + if (n + vec.len() > vec.capacity()) { | ||
3027 | + return false; | ||
3028 | + } else if (!vec.is_empty()) { | ||
3029 | + // move limbs | ||
3030 | + limb *dst = vec.data + n; | ||
3031 | + const limb *src = vec.data; | ||
3032 | + std::copy_backward(src, src + vec.len(), dst + vec.len()); | ||
3033 | + // fill in empty limbs | ||
3034 | + limb *first = vec.data; | ||
3035 | + limb *last = first + n; | ||
3036 | + ::std::fill(first, last, 0); | ||
3037 | + vec.set_len(n + vec.len()); | ||
3038 | + return true; | ||
3039 | + } else { | ||
3040 | + return true; | ||
3041 | + } | ||
3042 | + } | ||
3043 | + | ||
3044 | + // move the limbs left by `n` bits. | ||
3045 | + FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept { | ||
3046 | + size_t rem = n % limb_bits; | ||
3047 | + size_t div = n / limb_bits; | ||
3048 | + if (rem != 0) { | ||
3049 | + FASTFLOAT_TRY(shl_bits(rem)); | ||
3050 | + } | ||
3051 | + if (div != 0) { | ||
3052 | + FASTFLOAT_TRY(shl_limbs(div)); | ||
3053 | + } | ||
3054 | + return true; | ||
3055 | + } | ||
3056 | + | ||
3057 | + // get the number of leading zeros in the bigint. | ||
3058 | + FASTFLOAT_CONSTEXPR20 int ctlz() const noexcept { | ||
3059 | + if (vec.is_empty()) { | ||
3060 | + return 0; | ||
3061 | + } else { | ||
3062 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
3063 | + return leading_zeroes(vec.rindex(0)); | ||
3064 | +#else | ||
3065 | + // no use defining a specialized leading_zeroes for a 32-bit type. | ||
3066 | + uint64_t r0 = vec.rindex(0); | ||
3067 | + return leading_zeroes(r0 << 32); | ||
3068 | +#endif | ||
3069 | + } | ||
3070 | + } | ||
3071 | + | ||
3072 | + // get the number of bits in the bigint. | ||
3073 | + FASTFLOAT_CONSTEXPR20 int bit_length() const noexcept { | ||
3074 | + int lz = ctlz(); | ||
3075 | + return int(limb_bits * vec.len()) - lz; | ||
3076 | + } | ||
3077 | + | ||
3078 | + FASTFLOAT_CONSTEXPR20 bool mul(limb y) noexcept { return small_mul(vec, y); } | ||
3079 | + | ||
3080 | + FASTFLOAT_CONSTEXPR20 bool add(limb y) noexcept { return small_add(vec, y); } | ||
3081 | + | ||
3082 | + // multiply as if by 2 raised to a power. | ||
3083 | + FASTFLOAT_CONSTEXPR20 bool pow2(uint32_t exp) noexcept { return shl(exp); } | ||
3084 | + | ||
3085 | + // multiply as if by 5 raised to a power. | ||
3086 | + FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept { | ||
3087 | + // multiply by a power of 5 | ||
3088 | + size_t large_length = sizeof(large_power_of_5) / sizeof(limb); | ||
3089 | + limb_span large = limb_span(large_power_of_5, large_length); | ||
3090 | + while (exp >= large_step) { | ||
3091 | + FASTFLOAT_TRY(large_mul(vec, large)); | ||
3092 | + exp -= large_step; | ||
3093 | + } | ||
3094 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
3095 | + uint32_t small_step = 27; | ||
3096 | + limb max_native = 7450580596923828125UL; | ||
3097 | +#else | ||
3098 | + uint32_t small_step = 13; | ||
3099 | + limb max_native = 1220703125U; | ||
3100 | +#endif | ||
3101 | + while (exp >= small_step) { | ||
3102 | + FASTFLOAT_TRY(small_mul(vec, max_native)); | ||
3103 | + exp -= small_step; | ||
3104 | + } | ||
3105 | + if (exp != 0) { | ||
3106 | + // Work around clang bug https://godbolt.org/z/zedh7rrhc | ||
3107 | + // This is similar to https://github.com/llvm/llvm-project/issues/47746, | ||
3108 | + // except the workaround described there don't work here | ||
3109 | + FASTFLOAT_TRY(small_mul( | ||
3110 | + vec, limb(((void)small_power_of_5[0], small_power_of_5[exp])))); | ||
3111 | + } | ||
3112 | + | ||
3113 | + return true; | ||
3114 | + } | ||
3115 | + | ||
3116 | + // multiply as if by 10 raised to a power. | ||
3117 | + FASTFLOAT_CONSTEXPR20 bool pow10(uint32_t exp) noexcept { | ||
3118 | + FASTFLOAT_TRY(pow5(exp)); | ||
3119 | + return pow2(exp); | ||
3120 | + } | ||
3121 | +}; | ||
3122 | + | ||
3123 | +} // namespace fast_float | ||
3124 | + | ||
3125 | +#endif | ||
3126 | + | ||
3127 | +#ifndef FASTFLOAT_DIGIT_COMPARISON_H | ||
3128 | +#define FASTFLOAT_DIGIT_COMPARISON_H | ||
3129 | + | ||
3130 | +#include <algorithm> | ||
3131 | +#include <cstdint> | ||
3132 | +#include <cstring> | ||
3133 | +#include <iterator> | ||
3134 | + | ||
3135 | + | ||
3136 | +namespace fast_float { | ||
3137 | + | ||
3138 | +// 1e0 to 1e19 | ||
3139 | +constexpr static uint64_t powers_of_ten_uint64[] = {1UL, | ||
3140 | + 10UL, | ||
3141 | + 100UL, | ||
3142 | + 1000UL, | ||
3143 | + 10000UL, | ||
3144 | + 100000UL, | ||
3145 | + 1000000UL, | ||
3146 | + 10000000UL, | ||
3147 | + 100000000UL, | ||
3148 | + 1000000000UL, | ||
3149 | + 10000000000UL, | ||
3150 | + 100000000000UL, | ||
3151 | + 1000000000000UL, | ||
3152 | + 10000000000000UL, | ||
3153 | + 100000000000000UL, | ||
3154 | + 1000000000000000UL, | ||
3155 | + 10000000000000000UL, | ||
3156 | + 100000000000000000UL, | ||
3157 | + 1000000000000000000UL, | ||
3158 | + 10000000000000000000UL}; | ||
3159 | + | ||
3160 | +// calculate the exponent, in scientific notation, of the number. | ||
3161 | +// this algorithm is not even close to optimized, but it has no practical | ||
3162 | +// effect on performance: in order to have a faster algorithm, we'd need | ||
3163 | +// to slow down performance for faster algorithms, and this is still fast. | ||
3164 | +template <typename UC> | ||
3165 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int32_t | ||
3166 | +scientific_exponent(parsed_number_string_t<UC> &num) noexcept { | ||
3167 | + uint64_t mantissa = num.mantissa; | ||
3168 | + int32_t exponent = int32_t(num.exponent); | ||
3169 | + while (mantissa >= 10000) { | ||
3170 | + mantissa /= 10000; | ||
3171 | + exponent += 4; | ||
3172 | + } | ||
3173 | + while (mantissa >= 100) { | ||
3174 | + mantissa /= 100; | ||
3175 | + exponent += 2; | ||
3176 | + } | ||
3177 | + while (mantissa >= 10) { | ||
3178 | + mantissa /= 10; | ||
3179 | + exponent += 1; | ||
3180 | + } | ||
3181 | + return exponent; | ||
3182 | +} | ||
3183 | + | ||
3184 | +// this converts a native floating-point number to an extended-precision float. | ||
3185 | +template <typename T> | ||
3186 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa | ||
3187 | +to_extended(T value) noexcept { | ||
3188 | + using equiv_uint = typename binary_format<T>::equiv_uint; | ||
3189 | + constexpr equiv_uint exponent_mask = binary_format<T>::exponent_mask(); | ||
3190 | + constexpr equiv_uint mantissa_mask = binary_format<T>::mantissa_mask(); | ||
3191 | + constexpr equiv_uint hidden_bit_mask = binary_format<T>::hidden_bit_mask(); | ||
3192 | + | ||
3193 | + adjusted_mantissa am; | ||
3194 | + int32_t bias = binary_format<T>::mantissa_explicit_bits() - | ||
3195 | + binary_format<T>::minimum_exponent(); | ||
3196 | + equiv_uint bits; | ||
3197 | +#if FASTFLOAT_HAS_BIT_CAST | ||
3198 | + bits = std::bit_cast<equiv_uint>(value); | ||
3199 | +#else | ||
3200 | + ::memcpy(&bits, &value, sizeof(T)); | ||
3201 | +#endif | ||
3202 | + if ((bits & exponent_mask) == 0) { | ||
3203 | + // denormal | ||
3204 | + am.power2 = 1 - bias; | ||
3205 | + am.mantissa = bits & mantissa_mask; | ||
3206 | + } else { | ||
3207 | + // normal | ||
3208 | + am.power2 = int32_t((bits & exponent_mask) >> | ||
3209 | + binary_format<T>::mantissa_explicit_bits()); | ||
3210 | + am.power2 -= bias; | ||
3211 | + am.mantissa = (bits & mantissa_mask) | hidden_bit_mask; | ||
3212 | + } | ||
3213 | + | ||
3214 | + return am; | ||
3215 | +} | ||
3216 | + | ||
3217 | +// get the extended precision value of the halfway point between b and b+u. | ||
3218 | +// we are given a native float that represents b, so we need to adjust it | ||
3219 | +// halfway between b and b+u. | ||
3220 | +template <typename T> | ||
3221 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa | ||
3222 | +to_extended_halfway(T value) noexcept { | ||
3223 | + adjusted_mantissa am = to_extended(value); | ||
3224 | + am.mantissa <<= 1; | ||
3225 | + am.mantissa += 1; | ||
3226 | + am.power2 -= 1; | ||
3227 | + return am; | ||
3228 | +} | ||
3229 | + | ||
3230 | +// round an extended-precision float to the nearest machine float. | ||
3231 | +template <typename T, typename callback> | ||
3232 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void round(adjusted_mantissa &am, | ||
3233 | + callback cb) noexcept { | ||
3234 | + int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1; | ||
3235 | + if (-am.power2 >= mantissa_shift) { | ||
3236 | + // have a denormal float | ||
3237 | + int32_t shift = -am.power2 + 1; | ||
3238 | + cb(am, std::min<int32_t>(shift, 64)); | ||
3239 | + // check for round-up: if rounding-nearest carried us to the hidden bit. | ||
3240 | + am.power2 = (am.mantissa < | ||
3241 | + (uint64_t(1) << binary_format<T>::mantissa_explicit_bits())) | ||
3242 | + ? 0 | ||
3243 | + : 1; | ||
3244 | + return; | ||
3245 | + } | ||
3246 | + | ||
3247 | + // have a normal float, use the default shift. | ||
3248 | + cb(am, mantissa_shift); | ||
3249 | + | ||
3250 | + // check for carry | ||
3251 | + if (am.mantissa >= | ||
3252 | + (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) { | ||
3253 | + am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()); | ||
3254 | + am.power2++; | ||
3255 | + } | ||
3256 | + | ||
3257 | + // check for infinite: we could have carried to an infinite power | ||
3258 | + am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits()); | ||
3259 | + if (am.power2 >= binary_format<T>::infinite_power()) { | ||
3260 | + am.power2 = binary_format<T>::infinite_power(); | ||
3261 | + am.mantissa = 0; | ||
3262 | + } | ||
3263 | +} | ||
3264 | + | ||
3265 | +template <typename callback> | ||
3266 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void | ||
3267 | +round_nearest_tie_even(adjusted_mantissa &am, int32_t shift, | ||
3268 | + callback cb) noexcept { | ||
3269 | + const uint64_t mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1; | ||
3270 | + const uint64_t halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1); | ||
3271 | + uint64_t truncated_bits = am.mantissa & mask; | ||
3272 | + bool is_above = truncated_bits > halfway; | ||
3273 | + bool is_halfway = truncated_bits == halfway; | ||
3274 | + | ||
3275 | + // shift digits into position | ||
3276 | + if (shift == 64) { | ||
3277 | + am.mantissa = 0; | ||
3278 | + } else { | ||
3279 | + am.mantissa >>= shift; | ||
3280 | + } | ||
3281 | + am.power2 += shift; | ||
3282 | + | ||
3283 | + bool is_odd = (am.mantissa & 1) == 1; | ||
3284 | + am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above)); | ||
3285 | +} | ||
3286 | + | ||
3287 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void | ||
3288 | +round_down(adjusted_mantissa &am, int32_t shift) noexcept { | ||
3289 | + if (shift == 64) { | ||
3290 | + am.mantissa = 0; | ||
3291 | + } else { | ||
3292 | + am.mantissa >>= shift; | ||
3293 | + } | ||
3294 | + am.power2 += shift; | ||
3295 | +} | ||
3296 | +template <typename UC> | ||
3297 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
3298 | +skip_zeros(UC const *&first, UC const *last) noexcept { | ||
3299 | + uint64_t val; | ||
3300 | + while (!cpp20_and_in_constexpr() && | ||
3301 | + std::distance(first, last) >= int_cmp_len<UC>()) { | ||
3302 | + ::memcpy(&val, first, sizeof(uint64_t)); | ||
3303 | + if (val != int_cmp_zeros<UC>()) { | ||
3304 | + break; | ||
3305 | + } | ||
3306 | + first += int_cmp_len<UC>(); | ||
3307 | + } | ||
3308 | + while (first != last) { | ||
3309 | + if (*first != UC('0')) { | ||
3310 | + break; | ||
3311 | + } | ||
3312 | + first++; | ||
3313 | + } | ||
3314 | +} | ||
3315 | + | ||
3316 | +// determine if any non-zero digits were truncated. | ||
3317 | +// all characters must be valid digits. | ||
3318 | +template <typename UC> | ||
3319 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool | ||
3320 | +is_truncated(UC const *first, UC const *last) noexcept { | ||
3321 | + // do 8-bit optimizations, can just compare to 8 literal 0s. | ||
3322 | + uint64_t val; | ||
3323 | + while (!cpp20_and_in_constexpr() && | ||
3324 | + std::distance(first, last) >= int_cmp_len<UC>()) { | ||
3325 | + ::memcpy(&val, first, sizeof(uint64_t)); | ||
3326 | + if (val != int_cmp_zeros<UC>()) { | ||
3327 | + return true; | ||
3328 | + } | ||
3329 | + first += int_cmp_len<UC>(); | ||
3330 | + } | ||
3331 | + while (first != last) { | ||
3332 | + if (*first != UC('0')) { | ||
3333 | + return true; | ||
3334 | + } | ||
3335 | + ++first; | ||
3336 | + } | ||
3337 | + return false; | ||
3338 | +} | ||
3339 | +template <typename UC> | ||
3340 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool | ||
3341 | +is_truncated(span<const UC> s) noexcept { | ||
3342 | + return is_truncated(s.ptr, s.ptr + s.len()); | ||
3343 | +} | ||
3344 | + | ||
3345 | +template <typename UC> | ||
3346 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
3347 | +parse_eight_digits(const UC *&p, limb &value, size_t &counter, | ||
3348 | + size_t &count) noexcept { | ||
3349 | + value = value * 100000000 + parse_eight_digits_unrolled(p); | ||
3350 | + p += 8; | ||
3351 | + counter += 8; | ||
3352 | + count += 8; | ||
3353 | +} | ||
3354 | + | ||
3355 | +template <typename UC> | ||
3356 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR14 void | ||
3357 | +parse_one_digit(UC const *&p, limb &value, size_t &counter, | ||
3358 | + size_t &count) noexcept { | ||
3359 | + value = value * 10 + limb(*p - UC('0')); | ||
3360 | + p++; | ||
3361 | + counter++; | ||
3362 | + count++; | ||
3363 | +} | ||
3364 | + | ||
3365 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
3366 | +add_native(bigint &big, limb power, limb value) noexcept { | ||
3367 | + big.mul(power); | ||
3368 | + big.add(value); | ||
3369 | +} | ||
3370 | + | ||
3371 | +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void | ||
3372 | +round_up_bigint(bigint &big, size_t &count) noexcept { | ||
3373 | + // need to round-up the digits, but need to avoid rounding | ||
3374 | + // ....9999 to ...10000, which could cause a false halfway point. | ||
3375 | + add_native(big, 10, 1); | ||
3376 | + count++; | ||
3377 | +} | ||
3378 | + | ||
3379 | +// parse the significant digits into a big integer | ||
3380 | +template <typename UC> | ||
3381 | +inline FASTFLOAT_CONSTEXPR20 void | ||
3382 | +parse_mantissa(bigint &result, parsed_number_string_t<UC> &num, | ||
3383 | + size_t max_digits, size_t &digits) noexcept { | ||
3384 | + // try to minimize the number of big integer and scalar multiplication. | ||
3385 | + // therefore, try to parse 8 digits at a time, and multiply by the largest | ||
3386 | + // scalar value (9 or 19 digits) for each step. | ||
3387 | + size_t counter = 0; | ||
3388 | + digits = 0; | ||
3389 | + limb value = 0; | ||
3390 | +#ifdef FASTFLOAT_64BIT_LIMB | ||
3391 | + size_t step = 19; | ||
3392 | +#else | ||
3393 | + size_t step = 9; | ||
3394 | +#endif | ||
3395 | + | ||
3396 | + // process all integer digits. | ||
3397 | + UC const *p = num.integer.ptr; | ||
3398 | + UC const *pend = p + num.integer.len(); | ||
3399 | + skip_zeros(p, pend); | ||
3400 | + // process all digits, in increments of step per loop | ||
3401 | + while (p != pend) { | ||
3402 | + while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && | ||
3403 | + (max_digits - digits >= 8)) { | ||
3404 | + parse_eight_digits(p, value, counter, digits); | ||
3405 | + } | ||
3406 | + while (counter < step && p != pend && digits < max_digits) { | ||
3407 | + parse_one_digit(p, value, counter, digits); | ||
3408 | + } | ||
3409 | + if (digits == max_digits) { | ||
3410 | + // add the temporary value, then check if we've truncated any digits | ||
3411 | + add_native(result, limb(powers_of_ten_uint64[counter]), value); | ||
3412 | + bool truncated = is_truncated(p, pend); | ||
3413 | + if (num.fraction.ptr != nullptr) { | ||
3414 | + truncated |= is_truncated(num.fraction); | ||
3415 | + } | ||
3416 | + if (truncated) { | ||
3417 | + round_up_bigint(result, digits); | ||
3418 | + } | ||
3419 | + return; | ||
3420 | + } else { | ||
3421 | + add_native(result, limb(powers_of_ten_uint64[counter]), value); | ||
3422 | + counter = 0; | ||
3423 | + value = 0; | ||
3424 | + } | ||
3425 | + } | ||
3426 | + | ||
3427 | + // add our fraction digits, if they're available. | ||
3428 | + if (num.fraction.ptr != nullptr) { | ||
3429 | + p = num.fraction.ptr; | ||
3430 | + pend = p + num.fraction.len(); | ||
3431 | + if (digits == 0) { | ||
3432 | + skip_zeros(p, pend); | ||
3433 | + } | ||
3434 | + // process all digits, in increments of step per loop | ||
3435 | + while (p != pend) { | ||
3436 | + while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && | ||
3437 | + (max_digits - digits >= 8)) { | ||
3438 | + parse_eight_digits(p, value, counter, digits); | ||
3439 | + } | ||
3440 | + while (counter < step && p != pend && digits < max_digits) { | ||
3441 | + parse_one_digit(p, value, counter, digits); | ||
3442 | + } | ||
3443 | + if (digits == max_digits) { | ||
3444 | + // add the temporary value, then check if we've truncated any digits | ||
3445 | + add_native(result, limb(powers_of_ten_uint64[counter]), value); | ||
3446 | + bool truncated = is_truncated(p, pend); | ||
3447 | + if (truncated) { | ||
3448 | + round_up_bigint(result, digits); | ||
3449 | + } | ||
3450 | + return; | ||
3451 | + } else { | ||
3452 | + add_native(result, limb(powers_of_ten_uint64[counter]), value); | ||
3453 | + counter = 0; | ||
3454 | + value = 0; | ||
3455 | + } | ||
3456 | + } | ||
3457 | + } | ||
3458 | + | ||
3459 | + if (counter != 0) { | ||
3460 | + add_native(result, limb(powers_of_ten_uint64[counter]), value); | ||
3461 | + } | ||
3462 | +} | ||
3463 | + | ||
3464 | +template <typename T> | ||
3465 | +inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa | ||
3466 | +positive_digit_comp(bigint &bigmant, int32_t exponent) noexcept { | ||
3467 | + FASTFLOAT_ASSERT(bigmant.pow10(uint32_t(exponent))); | ||
3468 | + adjusted_mantissa answer; | ||
3469 | + bool truncated; | ||
3470 | + answer.mantissa = bigmant.hi64(truncated); | ||
3471 | + int bias = binary_format<T>::mantissa_explicit_bits() - | ||
3472 | + binary_format<T>::minimum_exponent(); | ||
3473 | + answer.power2 = bigmant.bit_length() - 64 + bias; | ||
3474 | + | ||
3475 | + round<T>(answer, [truncated](adjusted_mantissa &a, int32_t shift) { | ||
3476 | + round_nearest_tie_even( | ||
3477 | + a, shift, | ||
3478 | + [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool { | ||
3479 | + return is_above || (is_halfway && truncated) || | ||
3480 | + (is_odd && is_halfway); | ||
3481 | + }); | ||
3482 | + }); | ||
3483 | + | ||
3484 | + return answer; | ||
3485 | +} | ||
3486 | + | ||
3487 | +// the scaling here is quite simple: we have, for the real digits `m * 10^e`, | ||
3488 | +// and for the theoretical digits `n * 2^f`. Since `e` is always negative, | ||
3489 | +// to scale them identically, we do `n * 2^f * 5^-f`, so we now have `m * 2^e`. | ||
3490 | +// we then need to scale by `2^(f- e)`, and then the two significant digits | ||
3491 | +// are of the same magnitude. | ||
3492 | +template <typename T> | ||
3493 | +inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp( | ||
3494 | + bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept { | ||
3495 | + bigint &real_digits = bigmant; | ||
3496 | + int32_t real_exp = exponent; | ||
3497 | + | ||
3498 | + // get the value of `b`, rounded down, and get a bigint representation of b+h | ||
3499 | + adjusted_mantissa am_b = am; | ||
3500 | + // gcc7 buf: use a lambda to remove the noexcept qualifier bug with | ||
3501 | + // -Wnoexcept-type. | ||
3502 | + round<T>(am_b, | ||
3503 | + [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); }); | ||
3504 | + T b; | ||
3505 | + to_float(false, am_b, b); | ||
3506 | + adjusted_mantissa theor = to_extended_halfway(b); | ||
3507 | + bigint theor_digits(theor.mantissa); | ||
3508 | + int32_t theor_exp = theor.power2; | ||
3509 | + | ||
3510 | + // scale real digits and theor digits to be same power. | ||
3511 | + int32_t pow2_exp = theor_exp - real_exp; | ||
3512 | + uint32_t pow5_exp = uint32_t(-real_exp); | ||
3513 | + if (pow5_exp != 0) { | ||
3514 | + FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp)); | ||
3515 | + } | ||
3516 | + if (pow2_exp > 0) { | ||
3517 | + FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp))); | ||
3518 | + } else if (pow2_exp < 0) { | ||
3519 | + FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp))); | ||
3520 | + } | ||
3521 | + | ||
3522 | + // compare digits, and use it to director rounding | ||
3523 | + int ord = real_digits.compare(theor_digits); | ||
3524 | + adjusted_mantissa answer = am; | ||
3525 | + round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) { | ||
3526 | + round_nearest_tie_even( | ||
3527 | + a, shift, [ord](bool is_odd, bool _, bool __) -> bool { | ||
3528 | + (void)_; // not needed, since we've done our comparison | ||
3529 | + (void)__; // not needed, since we've done our comparison | ||
3530 | + if (ord > 0) { | ||
3531 | + return true; | ||
3532 | + } else if (ord < 0) { | ||
3533 | + return false; | ||
3534 | + } else { | ||
3535 | + return is_odd; | ||
3536 | + } | ||
3537 | + }); | ||
3538 | + }); | ||
3539 | + | ||
3540 | + return answer; | ||
3541 | +} | ||
3542 | + | ||
3543 | +// parse the significant digits as a big integer to unambiguously round the | ||
3544 | +// the significant digits. here, we are trying to determine how to round | ||
3545 | +// an extended float representation close to `b+h`, halfway between `b` | ||
3546 | +// (the float rounded-down) and `b+u`, the next positive float. this | ||
3547 | +// algorithm is always correct, and uses one of two approaches. when | ||
3548 | +// the exponent is positive relative to the significant digits (such as | ||
3549 | +// 1234), we create a big-integer representation, get the high 64-bits, | ||
3550 | +// determine if any lower bits are truncated, and use that to direct | ||
3551 | +// rounding. in case of a negative exponent relative to the significant | ||
3552 | +// digits (such as 1.2345), we create a theoretical representation of | ||
3553 | +// `b` as a big-integer type, scaled to the same binary exponent as | ||
3554 | +// the actual digits. we then compare the big integer representations | ||
3555 | +// of both, and use that to direct rounding. | ||
3556 | +template <typename T, typename UC> | ||
3557 | +inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa | ||
3558 | +digit_comp(parsed_number_string_t<UC> &num, adjusted_mantissa am) noexcept { | ||
3559 | + // remove the invalid exponent bias | ||
3560 | + am.power2 -= invalid_am_bias; | ||
3561 | + | ||
3562 | + int32_t sci_exp = scientific_exponent(num); | ||
3563 | + size_t max_digits = binary_format<T>::max_digits(); | ||
3564 | + size_t digits = 0; | ||
3565 | + bigint bigmant; | ||
3566 | + parse_mantissa(bigmant, num, max_digits, digits); | ||
3567 | + // can't underflow, since digits is at most max_digits. | ||
3568 | + int32_t exponent = sci_exp + 1 - int32_t(digits); | ||
3569 | + if (exponent >= 0) { | ||
3570 | + return positive_digit_comp<T>(bigmant, exponent); | ||
3571 | + } else { | ||
3572 | + return negative_digit_comp<T>(bigmant, am, exponent); | ||
3573 | + } | ||
3574 | +} | ||
3575 | + | ||
3576 | +} // namespace fast_float | ||
3577 | + | ||
3578 | +#endif | ||
3579 | + | ||
3580 | +#ifndef FASTFLOAT_PARSE_NUMBER_H | ||
3581 | +#define FASTFLOAT_PARSE_NUMBER_H | ||
3582 | + | ||
3583 | + | ||
3584 | +#include <cmath> | ||
3585 | +#include <cstring> | ||
3586 | +#include <limits> | ||
3587 | +#include <system_error> | ||
3588 | +namespace fast_float { | ||
3589 | + | ||
3590 | +namespace detail { | ||
3591 | +/** | ||
3592 | + * Special case +inf, -inf, nan, infinity, -infinity. | ||
3593 | + * The case comparisons could be made much faster given that we know that the | ||
3594 | + * strings a null-free and fixed. | ||
3595 | + **/ | ||
3596 | +template <typename T, typename UC> | ||
3597 | +from_chars_result_t<UC> FASTFLOAT_CONSTEXPR14 parse_infnan(UC const *first, | ||
3598 | + UC const *last, | ||
3599 | + T &value) noexcept { | ||
3600 | + from_chars_result_t<UC> answer{}; | ||
3601 | + answer.ptr = first; | ||
3602 | + answer.ec = std::errc(); // be optimistic | ||
3603 | + bool minusSign = false; | ||
3604 | + if (*first == | ||
3605 | + UC('-')) { // assume first < last, so dereference without checks; | ||
3606 | + // C++17 20.19.3.(7.1) explicitly forbids '+' here | ||
3607 | + minusSign = true; | ||
3608 | + ++first; | ||
3609 | + } | ||
3610 | +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default | ||
3611 | + if (*first == UC('+')) { | ||
3612 | + ++first; | ||
3613 | + } | ||
3614 | +#endif | ||
3615 | + if (last - first >= 3) { | ||
3616 | + if (fastfloat_strncasecmp(first, str_const_nan<UC>(), 3)) { | ||
3617 | + answer.ptr = (first += 3); | ||
3618 | + value = minusSign ? -std::numeric_limits<T>::quiet_NaN() | ||
3619 | + : std::numeric_limits<T>::quiet_NaN(); | ||
3620 | + // Check for possible nan(n-char-seq-opt), C++17 20.19.3.7, | ||
3621 | + // C11 7.20.1.3.3. At least MSVC produces nan(ind) and nan(snan). | ||
3622 | + if (first != last && *first == UC('(')) { | ||
3623 | + for (UC const *ptr = first + 1; ptr != last; ++ptr) { | ||
3624 | + if (*ptr == UC(')')) { | ||
3625 | + answer.ptr = ptr + 1; // valid nan(n-char-seq-opt) | ||
3626 | + break; | ||
3627 | + } else if (!((UC('a') <= *ptr && *ptr <= UC('z')) || | ||
3628 | + (UC('A') <= *ptr && *ptr <= UC('Z')) || | ||
3629 | + (UC('0') <= *ptr && *ptr <= UC('9')) || *ptr == UC('_'))) | ||
3630 | + break; // forbidden char, not nan(n-char-seq-opt) | ||
3631 | + } | ||
3632 | + } | ||
3633 | + return answer; | ||
3634 | + } | ||
3635 | + if (fastfloat_strncasecmp(first, str_const_inf<UC>(), 3)) { | ||
3636 | + if ((last - first >= 8) && | ||
3637 | + fastfloat_strncasecmp(first + 3, str_const_inf<UC>() + 3, 5)) { | ||
3638 | + answer.ptr = first + 8; | ||
3639 | + } else { | ||
3640 | + answer.ptr = first + 3; | ||
3641 | + } | ||
3642 | + value = minusSign ? -std::numeric_limits<T>::infinity() | ||
3643 | + : std::numeric_limits<T>::infinity(); | ||
3644 | + return answer; | ||
3645 | + } | ||
3646 | + } | ||
3647 | + answer.ec = std::errc::invalid_argument; | ||
3648 | + return answer; | ||
3649 | +} | ||
3650 | + | ||
3651 | +/** | ||
3652 | + * Returns true if the floating-pointing rounding mode is to 'nearest'. | ||
3653 | + * It is the default on most system. This function is meant to be inexpensive. | ||
3654 | + * Credit : @mwalcott3 | ||
3655 | + */ | ||
3656 | +fastfloat_really_inline bool rounds_to_nearest() noexcept { | ||
3657 | + // https://lemire.me/blog/2020/06/26/gcc-not-nearest/ | ||
3658 | +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) | ||
3659 | + return false; | ||
3660 | +#endif | ||
3661 | + // See | ||
3662 | + // A fast function to check your floating-point rounding mode | ||
3663 | + // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/ | ||
3664 | + // | ||
3665 | + // This function is meant to be equivalent to : | ||
3666 | + // prior: #include <cfenv> | ||
3667 | + // return fegetround() == FE_TONEAREST; | ||
3668 | + // However, it is expected to be much faster than the fegetround() | ||
3669 | + // function call. | ||
3670 | + // | ||
3671 | + // The volatile keywoard prevents the compiler from computing the function | ||
3672 | + // at compile-time. | ||
3673 | + // There might be other ways to prevent compile-time optimizations (e.g., | ||
3674 | + // asm). The value does not need to be std::numeric_limits<float>::min(), any | ||
3675 | + // small value so that 1 + x should round to 1 would do (after accounting for | ||
3676 | + // excess precision, as in 387 instructions). | ||
3677 | + static volatile float fmin = std::numeric_limits<float>::min(); | ||
3678 | + float fmini = fmin; // we copy it so that it gets loaded at most once. | ||
3679 | +// | ||
3680 | +// Explanation: | ||
3681 | +// Only when fegetround() == FE_TONEAREST do we have that | ||
3682 | +// fmin + 1.0f == 1.0f - fmin. | ||
3683 | +// | ||
3684 | +// FE_UPWARD: | ||
3685 | +// fmin + 1.0f > 1 | ||
3686 | +// 1.0f - fmin == 1 | ||
3687 | +// | ||
3688 | +// FE_DOWNWARD or FE_TOWARDZERO: | ||
3689 | +// fmin + 1.0f == 1 | ||
3690 | +// 1.0f - fmin < 1 | ||
3691 | +// | ||
3692 | +// Note: This may fail to be accurate if fast-math has been | ||
3693 | +// enabled, as rounding conventions may not apply. | ||
3694 | +#ifdef FASTFLOAT_VISUAL_STUDIO | ||
3695 | +#pragma warning(push) | ||
3696 | +// todo: is there a VS warning? | ||
3697 | +// see | ||
3698 | +// https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013 | ||
3699 | +#elif defined(__clang__) | ||
3700 | +#pragma clang diagnostic push | ||
3701 | +#pragma clang diagnostic ignored "-Wfloat-equal" | ||
3702 | +#elif defined(__GNUC__) | ||
3703 | +#pragma GCC diagnostic push | ||
3704 | +#pragma GCC diagnostic ignored "-Wfloat-equal" | ||
3705 | +#endif | ||
3706 | + return (fmini + 1.0f == 1.0f - fmini); | ||
3707 | +#ifdef FASTFLOAT_VISUAL_STUDIO | ||
3708 | +#pragma warning(pop) | ||
3709 | +#elif defined(__clang__) | ||
3710 | +#pragma clang diagnostic pop | ||
3711 | +#elif defined(__GNUC__) | ||
3712 | +#pragma GCC diagnostic pop | ||
3713 | +#endif | ||
3714 | +} | ||
3715 | + | ||
3716 | +} // namespace detail | ||
3717 | + | ||
3718 | +template <typename T> struct from_chars_caller { | ||
3719 | + template <typename UC> | ||
3720 | + FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC> | ||
3721 | + call(UC const *first, UC const *last, T &value, | ||
3722 | + parse_options_t<UC> options) noexcept { | ||
3723 | + return from_chars_advanced(first, last, value, options); | ||
3724 | + } | ||
3725 | +}; | ||
3726 | + | ||
3727 | +#if __STDCPP_FLOAT32_T__ == 1 | ||
3728 | +template <> struct from_chars_caller<std::float32_t> { | ||
3729 | + template <typename UC> | ||
3730 | + FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC> | ||
3731 | + call(UC const *first, UC const *last, std::float32_t &value, | ||
3732 | + parse_options_t<UC> options) noexcept { | ||
3733 | + // if std::float32_t is defined, and we are in C++23 mode; macro set for | ||
3734 | + // float32; set value to float due to equivalence between float and | ||
3735 | + // float32_t | ||
3736 | + float val; | ||
3737 | + auto ret = from_chars_advanced(first, last, val, options); | ||
3738 | + value = val; | ||
3739 | + return ret; | ||
3740 | + } | ||
3741 | +}; | ||
3742 | +#endif | ||
3743 | + | ||
3744 | +#if __STDCPP_FLOAT64_T__ == 1 | ||
3745 | +template <> struct from_chars_caller<std::float64_t> { | ||
3746 | + template <typename UC> | ||
3747 | + FASTFLOAT_CONSTEXPR20 static from_chars_result_t<UC> | ||
3748 | + call(UC const *first, UC const *last, std::float64_t &value, | ||
3749 | + parse_options_t<UC> options) noexcept { | ||
3750 | + // if std::float64_t is defined, and we are in C++23 mode; macro set for | ||
3751 | + // float64; set value as double due to equivalence between double and | ||
3752 | + // float64_t | ||
3753 | + double val; | ||
3754 | + auto ret = from_chars_advanced(first, last, val, options); | ||
3755 | + value = val; | ||
3756 | + return ret; | ||
3757 | + } | ||
3758 | +}; | ||
3759 | +#endif | ||
3760 | + | ||
3761 | +template <typename T, typename UC, typename> | ||
3762 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
3763 | +from_chars(UC const *first, UC const *last, T &value, | ||
3764 | + chars_format fmt /*= chars_format::general*/) noexcept { | ||
3765 | + return from_chars_caller<T>::call(first, last, value, | ||
3766 | + parse_options_t<UC>(fmt)); | ||
3767 | +} | ||
3768 | + | ||
3769 | +/** | ||
3770 | + * This function overload takes parsed_number_string_t structure that is created | ||
3771 | + * and populated either by from_chars_advanced function taking chars range and | ||
3772 | + * parsing options or other parsing custom function implemented by user. | ||
3773 | + */ | ||
3774 | +template <typename T, typename UC> | ||
3775 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
3776 | +from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept { | ||
3777 | + | ||
3778 | + static_assert(is_supported_float_type<T>(), | ||
3779 | + "only some floating-point types are supported"); | ||
3780 | + static_assert(is_supported_char_type<UC>(), | ||
3781 | + "only char, wchar_t, char16_t and char32_t are supported"); | ||
3782 | + | ||
3783 | + from_chars_result_t<UC> answer; | ||
3784 | + | ||
3785 | + answer.ec = std::errc(); // be optimistic | ||
3786 | + answer.ptr = pns.lastmatch; | ||
3787 | + // The implementation of the Clinger's fast path is convoluted because | ||
3788 | + // we want round-to-nearest in all cases, irrespective of the rounding mode | ||
3789 | + // selected on the thread. | ||
3790 | + // We proceed optimistically, assuming that detail::rounds_to_nearest() | ||
3791 | + // returns true. | ||
3792 | + if (binary_format<T>::min_exponent_fast_path() <= pns.exponent && | ||
3793 | + pns.exponent <= binary_format<T>::max_exponent_fast_path() && | ||
3794 | + !pns.too_many_digits) { | ||
3795 | + // Unfortunately, the conventional Clinger's fast path is only possible | ||
3796 | + // when the system rounds to the nearest float. | ||
3797 | + // | ||
3798 | + // We expect the next branch to almost always be selected. | ||
3799 | + // We could check it first (before the previous branch), but | ||
3800 | + // there might be performance advantages at having the check | ||
3801 | + // be last. | ||
3802 | + if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) { | ||
3803 | + // We have that fegetround() == FE_TONEAREST. | ||
3804 | + // Next is Clinger's fast path. | ||
3805 | + if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) { | ||
3806 | + value = T(pns.mantissa); | ||
3807 | + if (pns.exponent < 0) { | ||
3808 | + value = value / binary_format<T>::exact_power_of_ten(-pns.exponent); | ||
3809 | + } else { | ||
3810 | + value = value * binary_format<T>::exact_power_of_ten(pns.exponent); | ||
3811 | + } | ||
3812 | + if (pns.negative) { | ||
3813 | + value = -value; | ||
3814 | + } | ||
3815 | + return answer; | ||
3816 | + } | ||
3817 | + } else { | ||
3818 | + // We do not have that fegetround() == FE_TONEAREST. | ||
3819 | + // Next is a modified Clinger's fast path, inspired by Jakub Jelínek's | ||
3820 | + // proposal | ||
3821 | + if (pns.exponent >= 0 && | ||
3822 | + pns.mantissa <= | ||
3823 | + binary_format<T>::max_mantissa_fast_path(pns.exponent)) { | ||
3824 | +#if defined(__clang__) || defined(FASTFLOAT_32BIT) | ||
3825 | + // Clang may map 0 to -0.0 when fegetround() == FE_DOWNWARD | ||
3826 | + if (pns.mantissa == 0) { | ||
3827 | + value = pns.negative ? T(-0.) : T(0.); | ||
3828 | + return answer; | ||
3829 | + } | ||
3830 | +#endif | ||
3831 | + value = T(pns.mantissa) * | ||
3832 | + binary_format<T>::exact_power_of_ten(pns.exponent); | ||
3833 | + if (pns.negative) { | ||
3834 | + value = -value; | ||
3835 | + } | ||
3836 | + return answer; | ||
3837 | + } | ||
3838 | + } | ||
3839 | + } | ||
3840 | + adjusted_mantissa am = | ||
3841 | + compute_float<binary_format<T>>(pns.exponent, pns.mantissa); | ||
3842 | + if (pns.too_many_digits && am.power2 >= 0) { | ||
3843 | + if (am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) { | ||
3844 | + am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa); | ||
3845 | + } | ||
3846 | + } | ||
3847 | + // If we called compute_float<binary_format<T>>(pns.exponent, pns.mantissa) | ||
3848 | + // and we have an invalid power (am.power2 < 0), then we need to go the long | ||
3849 | + // way around again. This is very uncommon. | ||
3850 | + if (am.power2 < 0) { | ||
3851 | + am = digit_comp<T>(pns, am); | ||
3852 | + } | ||
3853 | + to_float(pns.negative, am, value); | ||
3854 | + // Test for over/underflow. | ||
3855 | + if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) || | ||
3856 | + am.power2 == binary_format<T>::infinite_power()) { | ||
3857 | + answer.ec = std::errc::result_out_of_range; | ||
3858 | + } | ||
3859 | + return answer; | ||
3860 | +} | ||
3861 | + | ||
3862 | +template <typename T, typename UC> | ||
3863 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
3864 | +from_chars_advanced(UC const *first, UC const *last, T &value, | ||
3865 | + parse_options_t<UC> options) noexcept { | ||
3866 | + | ||
3867 | + static_assert(is_supported_float_type<T>(), | ||
3868 | + "only some floating-point types are supported"); | ||
3869 | + static_assert(is_supported_char_type<UC>(), | ||
3870 | + "only char, wchar_t, char16_t and char32_t are supported"); | ||
3871 | + | ||
3872 | + from_chars_result_t<UC> answer; | ||
3873 | +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default | ||
3874 | + while ((first != last) && fast_float::is_space(uint8_t(*first))) { | ||
3875 | + first++; | ||
3876 | + } | ||
3877 | +#endif | ||
3878 | + if (first == last) { | ||
3879 | + answer.ec = std::errc::invalid_argument; | ||
3880 | + answer.ptr = first; | ||
3881 | + return answer; | ||
3882 | + } | ||
3883 | + parsed_number_string_t<UC> pns = | ||
3884 | + parse_number_string<UC>(first, last, options); | ||
3885 | + if (!pns.valid) { | ||
3886 | + if (options.format & chars_format::no_infnan) { | ||
3887 | + answer.ec = std::errc::invalid_argument; | ||
3888 | + answer.ptr = first; | ||
3889 | + return answer; | ||
3890 | + } else { | ||
3891 | + return detail::parse_infnan(first, last, value); | ||
3892 | + } | ||
3893 | + } | ||
3894 | + | ||
3895 | + // call overload that takes parsed_number_string_t directly. | ||
3896 | + return from_chars_advanced(pns, value); | ||
3897 | +} | ||
3898 | + | ||
3899 | +template <typename T, typename UC, typename> | ||
3900 | +FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> | ||
3901 | +from_chars(UC const *first, UC const *last, T &value, int base) noexcept { | ||
3902 | + static_assert(is_supported_char_type<UC>(), | ||
3903 | + "only char, wchar_t, char16_t and char32_t are supported"); | ||
3904 | + | ||
3905 | + from_chars_result_t<UC> answer; | ||
3906 | +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default | ||
3907 | + while ((first != last) && fast_float::is_space(uint8_t(*first))) { | ||
3908 | + first++; | ||
3909 | + } | ||
3910 | +#endif | ||
3911 | + if (first == last || base < 2 || base > 36) { | ||
3912 | + answer.ec = std::errc::invalid_argument; | ||
3913 | + answer.ptr = first; | ||
3914 | + return answer; | ||
3915 | + } | ||
3916 | + return parse_int_string(first, last, value, base); | ||
3917 | +} | ||
3918 | + | ||
3919 | +} // namespace fast_float | ||
3920 | + | ||
3921 | +#endif | ||
3922 | + | ||
diff --git a/meta/recipes-support/vte/vte/0005-color-parser-Use-fast_float-implementation-for-from_.patch b/meta/recipes-support/vte/vte/0005-color-parser-Use-fast_float-implementation-for-from_.patch deleted file mode 100644 index b951bbac18..0000000000 --- a/meta/recipes-support/vte/vte/0005-color-parser-Use-fast_float-implementation-for-from_.patch +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | From 08b90d0a5bf8ceb68dd1b4e9ded0f8a2b5287a6e Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 4 Oct 2024 21:22:52 -0700 | ||
4 | Subject: [PATCH 5/5] color-parser: Use fast_float implementation for | ||
5 | from_chars | ||
6 | |||
7 | Removed dependency on c++ runtime to provide it. | ||
8 | |||
9 | Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2823 | ||
10 | |||
11 | Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/vte/-/issues/2823#note_2239888] | ||
12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
13 | --- | ||
14 | src/color-parser.cc | 12 ++++++------ | ||
15 | src/termprops.hh | 12 ++++++------ | ||
16 | 2 files changed, 12 insertions(+), 12 deletions(-) | ||
17 | |||
18 | diff --git a/src/color-parser.cc b/src/color-parser.cc | ||
19 | index 02ec5d3a..42c51966 100644 | ||
20 | --- a/src/color-parser.cc | ||
21 | +++ b/src/color-parser.cc | ||
22 | @@ -17,7 +17,7 @@ | ||
23 | |||
24 | #include "color-parser.hh" | ||
25 | #include "color.hh" | ||
26 | - | ||
27 | +#include "fast_float.hh" | ||
28 | #include <algorithm> | ||
29 | #include <cctype> | ||
30 | #include <charconv> | ||
31 | @@ -298,7 +298,7 @@ parse_csslike(std::string const& spec) noexcept | ||
32 | auto value = uint64_t{}; | ||
33 | auto const start = spec.c_str() + 1; | ||
34 | auto const end = spec.c_str() + spec.size(); | ||
35 | - auto const rv = std::from_chars(start, end, value, 16); | ||
36 | + auto const rv = fast_float::from_chars(start, end, value, 16); | ||
37 | if (rv.ec != std::errc{} || rv.ptr != end) | ||
38 | return std::nullopt; | ||
39 | |||
40 | @@ -424,7 +424,7 @@ parse_x11like(std::string const& spec) noexcept | ||
41 | auto value = uint64_t{}; | ||
42 | auto const start = spec.c_str() + 1; | ||
43 | auto const end = spec.c_str() + spec.size(); | ||
44 | - auto const rv = std::from_chars(start, end, value, 16); | ||
45 | + auto const rv = fast_float::from_chars(start, end, value, 16); | ||
46 | if (rv.ec != std::errc{} || rv.ptr != end) | ||
47 | return std::nullopt; | ||
48 | |||
49 | @@ -447,13 +447,13 @@ parse_x11like(std::string const& spec) noexcept | ||
50 | // Note that the length check above makes sure that @r, @g, @b, | ||
51 | // don't exceed @bits. | ||
52 | auto r = UINT64_C(0), b = UINT64_C(0), g = UINT64_C(0); | ||
53 | - auto rv = std::from_chars(start, end, r, 16); | ||
54 | + auto rv = fast_float::from_chars(start, end, r, 16); | ||
55 | if (rv.ec != std::errc{} || rv.ptr == end || *rv.ptr != '/') | ||
56 | return std::nullopt; | ||
57 | - rv = std::from_chars(rv.ptr + 1, end, g, 16); | ||
58 | + rv = fast_float::from_chars(rv.ptr + 1, end, g, 16); | ||
59 | if (rv.ec != std::errc{} || rv.ptr == end || *rv.ptr != '/') | ||
60 | return std::nullopt; | ||
61 | - rv = std::from_chars(rv.ptr + 1, end, b, 16); | ||
62 | + rv = fast_float::from_chars(rv.ptr + 1, end, b, 16); | ||
63 | if (rv.ec != std::errc{} || rv.ptr != end) | ||
64 | return std::nullopt; | ||
65 | |||
66 | diff --git a/src/termprops.hh b/src/termprops.hh | ||
67 | index 0d3f0f4c..a10fc7d1 100644 | ||
68 | --- a/src/termprops.hh | ||
69 | +++ b/src/termprops.hh | ||
70 | @@ -17,6 +17,7 @@ | ||
71 | |||
72 | #include <glib.h> | ||
73 | |||
74 | +#include "fast_float.hh" | ||
75 | #include "fwd.hh" | ||
76 | #include "uuid.hh" | ||
77 | #include "color.hh" | ||
78 | @@ -355,8 +356,8 @@ inline std::optional<TermpropValue> | ||
79 | parse_termprop_integral(std::string_view const& str) noexcept | ||
80 | { | ||
81 | auto v = T{}; | ||
82 | - if (auto [ptr, err] = std::from_chars(std::begin(str), | ||
83 | - std::end(str), | ||
84 | + if (auto [ptr, err] = fast_float::from_chars(str.data(), | ||
85 | + str.data()+str.size(), | ||
86 | v); | ||
87 | err == std::errc() && ptr == std::end(str)) { | ||
88 | if constexpr (std::is_unsigned_v<T>) { | ||
89 | @@ -389,10 +390,9 @@ inline std::optional<TermpropValue> | ||
90 | parse_termprop_floating(std::string_view const& str) noexcept | ||
91 | { | ||
92 | auto v = T{}; | ||
93 | - if (auto [ptr, err] = std::from_chars(std::begin(str), | ||
94 | - std::end(str), | ||
95 | - v, | ||
96 | - std::chars_format::general); | ||
97 | + if (auto [ptr, err] = fast_float::from_chars(str.data(), | ||
98 | + str.data() + str.size(), | ||
99 | + v); | ||
100 | err == std::errc() && | ||
101 | ptr == std::end(str) && | ||
102 | std::isfinite(v)) { | ||
diff --git a/meta/recipes-support/vte/vte_0.78.2.bb b/meta/recipes-support/vte/vte_0.80.3.bb index 0593d16cd8..1eb95dd827 100644 --- a/meta/recipes-support/vte/vte_0.78.2.bb +++ b/meta/recipes-support/vte/vte_0.80.3.bb | |||
@@ -11,18 +11,15 @@ LIC_FILES_CHKSUM = " \ | |||
11 | file://COPYING.XTERM;md5=d7fc3a23c16c039afafe2e042030f057 \ | 11 | file://COPYING.XTERM;md5=d7fc3a23c16c039afafe2e042030f057 \ |
12 | " | 12 | " |
13 | 13 | ||
14 | DEPENDS = "glib-2.0 glib-2.0-native gtk+3 libpcre2 libxml2-native gperf-native icu lz4" | 14 | DEPENDS = "fastfloat glib-2.0 glib-2.0-native gtk+3 libpcre2 libxml2-native gperf-native icu lz4" |
15 | 15 | ||
16 | GIR_MESON_OPTION = 'gir' | 16 | GIR_MESON_OPTION = 'gir' |
17 | GIDOCGEN_MESON_OPTION = "docs" | 17 | GIDOCGEN_MESON_OPTION = "docs" |
18 | inherit gnomebase gi-docgen features_check upstream-version-is-even gobject-introspection systemd vala | 18 | inherit gnomebase gi-docgen features_check upstream-version-is-even gobject-introspection systemd vala |
19 | 19 | ||
20 | SRC_URI += "file://0001-Add-W_EXITCODE-macro-for-non-glibc-systems.patch \ | 20 | SRC_URI += "file://0001-Add-W_EXITCODE-macro-for-non-glibc-systems.patch" |
21 | file://0002-lib-Typo-fix.patch \ | 21 | |
22 | file://0004-fast_float-Add-single-header-library-for-from_char-i.patch \ | 22 | SRC_URI[archive.sha256sum] = "2e596fd3fbeabb71531662224e71f6a2c37f684426136d62854627276ef4f699" |
23 | file://0005-color-parser-Use-fast_float-implementation-for-from_.patch \ | ||
24 | " | ||
25 | SRC_URI[archive.sha256sum] = "35d7bcde07356846b4a12881c8e016705b70a9004a9082285eee5834ccc49890" | ||
26 | 23 | ||
27 | ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}" | 24 | ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}" |
28 | 25 | ||
@@ -49,7 +46,8 @@ FILES:${PN}-gtk4-dev = "${libdir}/lib*gtk4.so \ | |||
49 | ${datadir}/vala/vapi/vte-2.91-gtk4.vapi \ | 46 | ${datadir}/vala/vapi/vte-2.91-gtk4.vapi \ |
50 | ${includedir}/vte-2.91-gtk4 \ | 47 | ${includedir}/vte-2.91-gtk4 \ |
51 | " | 48 | " |
52 | FILES:${PN} += "${systemd_user_unitdir}" | 49 | FILES:${PN} += "${systemd_user_unitdir} \ |
50 | ${datadir}/xdg-terminals" | ||
53 | FILES:libvte = "${libdir}/*.so.* ${libdir}/girepository-1.0/*" | 51 | FILES:libvte = "${libdir}/*.so.* ${libdir}/girepository-1.0/*" |
54 | FILES:${PN}-prompt = " \ | 52 | FILES:${PN}-prompt = " \ |
55 | ${sysconfdir}/profile.d \ | 53 | ${sysconfdir}/profile.d \ |