diff --git a/LEGAL b/LEGAL index dfc7189b..3d3e0935 100644 --- a/LEGAL +++ b/LEGAL @@ -15,6 +15,6 @@ ext/json/ext/vendor/jeaiii-ltoa.h:: This file is adapted from https://github.com/jeaiii/itoa It is licensed under the MIT License -ext/json/ext/vendor/ryu.h:: - This file is adapted from the Ryu algorithm by Ulf Adams https://github.com/ulfjack/ryu. - It is dual-licensed under Apache License 2.0 OR Boost Software License 1.0. +ext/json/ext/vendor/fast_float_parser.h:: + This file is adapted from the Fast Float C++ library by The fast_float authors https://github.com/fastfloat/fast_float + It is licensed under the MIT License diff --git a/ext/json/ext/parser/depend b/ext/json/ext/parser/depend index 5d75ef24..53aa89b7 100644 --- a/ext/json/ext/parser/depend +++ b/ext/json/ext/parser/depend @@ -2,6 +2,6 @@ parser.o: $(srcdir)/../fbuffer/fbuffer.h parser.o: $(srcdir)/../json.h parser.o: $(srcdir)/../simd/simd.h -parser.o: $(srcdir)/../vendor/ryu.h +parser.o: $(srcdir)/../vendor/fast_float_parser.h parser.o: parser.c # AUTOGENERATED DEPENDENCIES END diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 15e79b24..d130b868 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1,5 +1,5 @@ #include "../json.h" -#include "../vendor/ryu.h" +#include "../vendor/fast_float_parser.h" #include "../simd/simd.h" static VALUE mJSON, eNestingError, eParserError, Encoding_UTF_8; @@ -1111,13 +1111,11 @@ static inline VALUE json_decode_float(JSON_ParserConfig *config, uint64_t mantis return rb_float_new(negative ? -0.0 : 0.0); } - // Fall back to rb_cstr_to_dbl for potential subnormals (rare edge case) - // Ryu has rounding issues with subnormals around 1e-310 (< 2.225e-308) - if (RB_UNLIKELY(mantissa_digits > 17 || mantissa_digits + exponent < -307)) { + if (RB_UNLIKELY(mantissa_digits > 18 || mantissa_digits + exponent < -307)) { return json_decode_large_float(start, end - start); } - return DBL2NUM(ryu_s2d_from_parts(mantissa, mantissa_digits, (int32_t)exponent, negative)); + return DBL2NUM(ffp_s2d(exponent, mantissa, negative)); } static inline VALUE json_decode_array(JSON_ParserState *state, JSON_ParserConfig *config, long count) diff --git a/ext/json/ext/vendor/fast_float_parser.h b/ext/json/ext/vendor/fast_float_parser.h new file mode 100644 index 00000000..00c1f155 --- /dev/null +++ b/ext/json/ext/vendor/fast_float_parser.h @@ -0,0 +1,804 @@ +/* Eisel-Lemire decimal->double, ported from fast_float: + * include/fast_float/decimal_to_binary.h, the compute_float> + * + compute_product_approximation routines. + * + * Algorithm authors: Michael Eisel (original approach) and Daniel Lemire + * (formalization, proof, and the fast_float implementation) — hence "Eisel-Lemire". + * + * Copyright (c) 2021 The fast_float authors. Tri-licensed Apache-2.0 / MIT / BSL-1.0; + * used here under MIT — see LICENSE-fast_float-MIT in this directory. + * + * C99 Port by Tilo Sloboda. + */ + +#ifndef FFP_H +#define FFP_H +#include +#include +#include + +#define FFP_SMALLEST_POWER_OF_FIVE (-342) +#define FFP_LARGEST_POWER_OF_FIVE (308) +static const uint64_t ffp_power_of_five_128[2 * (308 - (-342) + 1)] = { + 0xeef453d6923bd65a, 0x113faa2906a13b3f, + 0x9558b4661b6565f8, 0x4ac7ca59a424c507, + 0xbaaee17fa23ebf76, 0x5d79bcf00d2df649, + 0xe95a99df8ace6f53, 0xf4d82c2c107973dc, + 0x91d8a02bb6c10594, 0x79071b9b8a4be869, + 0xb64ec836a47146f9, 0x9748e2826cdee284, + 0xe3e27a444d8d98b7, 0xfd1b1b2308169b25, + 0x8e6d8c6ab0787f72, 0xfe30f0f5e50e20f7, + 0xb208ef855c969f4f, 0xbdbd2d335e51a935, + 0xde8b2b66b3bc4723, 0xad2c788035e61382, + 0x8b16fb203055ac76, 0x4c3bcb5021afcc31, + 0xaddcb9e83c6b1793, 0xdf4abe242a1bbf3d, + 0xd953e8624b85dd78, 0xd71d6dad34a2af0d, + 0x87d4713d6f33aa6b, 0x8672648c40e5ad68, + 0xa9c98d8ccb009506, 0x680efdaf511f18c2, + 0xd43bf0effdc0ba48, 0x212bd1b2566def2, + 0x84a57695fe98746d, 0x14bb630f7604b57, + 0xa5ced43b7e3e9188, 0x419ea3bd35385e2d, + 0xcf42894a5dce35ea, 0x52064cac828675b9, + 0x818995ce7aa0e1b2, 0x7343efebd1940993, + 0xa1ebfb4219491a1f, 0x1014ebe6c5f90bf8, + 0xca66fa129f9b60a6, 0xd41a26e077774ef6, + 0xfd00b897478238d0, 0x8920b098955522b4, + 0x9e20735e8cb16382, 0x55b46e5f5d5535b0, + 0xc5a890362fddbc62, 0xeb2189f734aa831d, + 0xf712b443bbd52b7b, 0xa5e9ec7501d523e4, + 0x9a6bb0aa55653b2d, 0x47b233c92125366e, + 0xc1069cd4eabe89f8, 0x999ec0bb696e840a, + 0xf148440a256e2c76, 0xc00670ea43ca250d, + 0x96cd2a865764dbca, 0x380406926a5e5728, + 0xbc807527ed3e12bc, 0xc605083704f5ecf2, + 0xeba09271e88d976b, 0xf7864a44c633682e, + 0x93445b8731587ea3, 0x7ab3ee6afbe0211d, + 0xb8157268fdae9e4c, 0x5960ea05bad82964, + 0xe61acf033d1a45df, 0x6fb92487298e33bd, + 0x8fd0c16206306bab, 0xa5d3b6d479f8e056, + 0xb3c4f1ba87bc8696, 0x8f48a4899877186c, + 0xe0b62e2929aba83c, 0x331acdabfe94de87, + 0x8c71dcd9ba0b4925, 0x9ff0c08b7f1d0b14, + 0xaf8e5410288e1b6f, 0x7ecf0ae5ee44dd9, + 0xdb71e91432b1a24a, 0xc9e82cd9f69d6150, + 0x892731ac9faf056e, 0xbe311c083a225cd2, + 0xab70fe17c79ac6ca, 0x6dbd630a48aaf406, + 0xd64d3d9db981787d, 0x92cbbccdad5b108, + 0x85f0468293f0eb4e, 0x25bbf56008c58ea5, + 0xa76c582338ed2621, 0xaf2af2b80af6f24e, + 0xd1476e2c07286faa, 0x1af5af660db4aee1, + 0x82cca4db847945ca, 0x50d98d9fc890ed4d, + 0xa37fce126597973c, 0xe50ff107bab528a0, + 0xcc5fc196fefd7d0c, 0x1e53ed49a96272c8, + 0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7a, + 0x9faacf3df73609b1, 0x77b191618c54e9ac, + 0xc795830d75038c1d, 0xd59df5b9ef6a2417, + 0xf97ae3d0d2446f25, 0x4b0573286b44ad1d, + 0x9becce62836ac577, 0x4ee367f9430aec32, + 0xc2e801fb244576d5, 0x229c41f793cda73f, + 0xf3a20279ed56d48a, 0x6b43527578c1110f, + 0x9845418c345644d6, 0x830a13896b78aaa9, + 0xbe5691ef416bd60c, 0x23cc986bc656d553, + 0xedec366b11c6cb8f, 0x2cbfbe86b7ec8aa8, + 0x94b3a202eb1c3f39, 0x7bf7d71432f3d6a9, + 0xb9e08a83a5e34f07, 0xdaf5ccd93fb0cc53, + 0xe858ad248f5c22c9, 0xd1b3400f8f9cff68, + 0x91376c36d99995be, 0x23100809b9c21fa1, + 0xb58547448ffffb2d, 0xabd40a0c2832a78a, + 0xe2e69915b3fff9f9, 0x16c90c8f323f516c, + 0x8dd01fad907ffc3b, 0xae3da7d97f6792e3, + 0xb1442798f49ffb4a, 0x99cd11cfdf41779c, + 0xdd95317f31c7fa1d, 0x40405643d711d583, + 0x8a7d3eef7f1cfc52, 0x482835ea666b2572, + 0xad1c8eab5ee43b66, 0xda3243650005eecf, + 0xd863b256369d4a40, 0x90bed43e40076a82, + 0x873e4f75e2224e68, 0x5a7744a6e804a291, + 0xa90de3535aaae202, 0x711515d0a205cb36, + 0xd3515c2831559a83, 0xd5a5b44ca873e03, + 0x8412d9991ed58091, 0xe858790afe9486c2, + 0xa5178fff668ae0b6, 0x626e974dbe39a872, + 0xce5d73ff402d98e3, 0xfb0a3d212dc8128f, + 0x80fa687f881c7f8e, 0x7ce66634bc9d0b99, + 0xa139029f6a239f72, 0x1c1fffc1ebc44e80, + 0xc987434744ac874e, 0xa327ffb266b56220, + 0xfbe9141915d7a922, 0x4bf1ff9f0062baa8, + 0x9d71ac8fada6c9b5, 0x6f773fc3603db4a9, + 0xc4ce17b399107c22, 0xcb550fb4384d21d3, + 0xf6019da07f549b2b, 0x7e2a53a146606a48, + 0x99c102844f94e0fb, 0x2eda7444cbfc426d, + 0xc0314325637a1939, 0xfa911155fefb5308, + 0xf03d93eebc589f88, 0x793555ab7eba27ca, + 0x96267c7535b763b5, 0x4bc1558b2f3458de, + 0xbbb01b9283253ca2, 0x9eb1aaedfb016f16, + 0xea9c227723ee8bcb, 0x465e15a979c1cadc, + 0x92a1958a7675175f, 0xbfacd89ec191ec9, + 0xb749faed14125d36, 0xcef980ec671f667b, + 0xe51c79a85916f484, 0x82b7e12780e7401a, + 0x8f31cc0937ae58d2, 0xd1b2ecb8b0908810, + 0xb2fe3f0b8599ef07, 0x861fa7e6dcb4aa15, + 0xdfbdcece67006ac9, 0x67a791e093e1d49a, + 0x8bd6a141006042bd, 0xe0c8bb2c5c6d24e0, + 0xaecc49914078536d, 0x58fae9f773886e18, + 0xda7f5bf590966848, 0xaf39a475506a899e, + 0x888f99797a5e012d, 0x6d8406c952429603, + 0xaab37fd7d8f58178, 0xc8e5087ba6d33b83, + 0xd5605fcdcf32e1d6, 0xfb1e4a9a90880a64, + 0x855c3be0a17fcd26, 0x5cf2eea09a55067f, + 0xa6b34ad8c9dfc06f, 0xf42faa48c0ea481e, + 0xd0601d8efc57b08b, 0xf13b94daf124da26, + 0x823c12795db6ce57, 0x76c53d08d6b70858, + 0xa2cb1717b52481ed, 0x54768c4b0c64ca6e, + 0xcb7ddcdda26da268, 0xa9942f5dcf7dfd09, + 0xfe5d54150b090b02, 0xd3f93b35435d7c4c, + 0x9efa548d26e5a6e1, 0xc47bc5014a1a6daf, + 0xc6b8e9b0709f109a, 0x359ab6419ca1091b, + 0xf867241c8cc6d4c0, 0xc30163d203c94b62, + 0x9b407691d7fc44f8, 0x79e0de63425dcf1d, + 0xc21094364dfb5636, 0x985915fc12f542e4, + 0xf294b943e17a2bc4, 0x3e6f5b7b17b2939d, + 0x979cf3ca6cec5b5a, 0xa705992ceecf9c42, + 0xbd8430bd08277231, 0x50c6ff782a838353, + 0xece53cec4a314ebd, 0xa4f8bf5635246428, + 0x940f4613ae5ed136, 0x871b7795e136be99, + 0xb913179899f68584, 0x28e2557b59846e3f, + 0xe757dd7ec07426e5, 0x331aeada2fe589cf, + 0x9096ea6f3848984f, 0x3ff0d2c85def7621, + 0xb4bca50b065abe63, 0xfed077a756b53a9, + 0xe1ebce4dc7f16dfb, 0xd3e8495912c62894, + 0x8d3360f09cf6e4bd, 0x64712dd7abbbd95c, + 0xb080392cc4349dec, 0xbd8d794d96aacfb3, + 0xdca04777f541c567, 0xecf0d7a0fc5583a0, + 0x89e42caaf9491b60, 0xf41686c49db57244, + 0xac5d37d5b79b6239, 0x311c2875c522ced5, + 0xd77485cb25823ac7, 0x7d633293366b828b, + 0x86a8d39ef77164bc, 0xae5dff9c02033197, + 0xa8530886b54dbdeb, 0xd9f57f830283fdfc, + 0xd267caa862a12d66, 0xd072df63c324fd7b, + 0x8380dea93da4bc60, 0x4247cb9e59f71e6d, + 0xa46116538d0deb78, 0x52d9be85f074e608, + 0xcd795be870516656, 0x67902e276c921f8b, + 0x806bd9714632dff6, 0xba1cd8a3db53b6, + 0xa086cfcd97bf97f3, 0x80e8a40eccd228a4, + 0xc8a883c0fdaf7df0, 0x6122cd128006b2cd, + 0xfad2a4b13d1b5d6c, 0x796b805720085f81, + 0x9cc3a6eec6311a63, 0xcbe3303674053bb0, + 0xc3f490aa77bd60fc, 0xbedbfc4411068a9c, + 0xf4f1b4d515acb93b, 0xee92fb5515482d44, + 0x991711052d8bf3c5, 0x751bdd152d4d1c4a, + 0xbf5cd54678eef0b6, 0xd262d45a78a0635d, + 0xef340a98172aace4, 0x86fb897116c87c34, + 0x9580869f0e7aac0e, 0xd45d35e6ae3d4da0, + 0xbae0a846d2195712, 0x8974836059cca109, + 0xe998d258869facd7, 0x2bd1a438703fc94b, + 0x91ff83775423cc06, 0x7b6306a34627ddcf, + 0xb67f6455292cbf08, 0x1a3bc84c17b1d542, + 0xe41f3d6a7377eeca, 0x20caba5f1d9e4a93, + 0x8e938662882af53e, 0x547eb47b7282ee9c, + 0xb23867fb2a35b28d, 0xe99e619a4f23aa43, + 0xdec681f9f4c31f31, 0x6405fa00e2ec94d4, + 0x8b3c113c38f9f37e, 0xde83bc408dd3dd04, + 0xae0b158b4738705e, 0x9624ab50b148d445, + 0xd98ddaee19068c76, 0x3badd624dd9b0957, + 0x87f8a8d4cfa417c9, 0xe54ca5d70a80e5d6, + 0xa9f6d30a038d1dbc, 0x5e9fcf4ccd211f4c, + 0xd47487cc8470652b, 0x7647c3200069671f, + 0x84c8d4dfd2c63f3b, 0x29ecd9f40041e073, + 0xa5fb0a17c777cf09, 0xf468107100525890, + 0xcf79cc9db955c2cc, 0x7182148d4066eeb4, + 0x81ac1fe293d599bf, 0xc6f14cd848405530, + 0xa21727db38cb002f, 0xb8ada00e5a506a7c, + 0xca9cf1d206fdc03b, 0xa6d90811f0e4851c, + 0xfd442e4688bd304a, 0x908f4a166d1da663, + 0x9e4a9cec15763e2e, 0x9a598e4e043287fe, + 0xc5dd44271ad3cdba, 0x40eff1e1853f29fd, + 0xf7549530e188c128, 0xd12bee59e68ef47c, + 0x9a94dd3e8cf578b9, 0x82bb74f8301958ce, + 0xc13a148e3032d6e7, 0xe36a52363c1faf01, + 0xf18899b1bc3f8ca1, 0xdc44e6c3cb279ac1, + 0x96f5600f15a7b7e5, 0x29ab103a5ef8c0b9, + 0xbcb2b812db11a5de, 0x7415d448f6b6f0e7, + 0xebdf661791d60f56, 0x111b495b3464ad21, + 0x936b9fcebb25c995, 0xcab10dd900beec34, + 0xb84687c269ef3bfb, 0x3d5d514f40eea742, + 0xe65829b3046b0afa, 0xcb4a5a3112a5112, + 0x8ff71a0fe2c2e6dc, 0x47f0e785eaba72ab, + 0xb3f4e093db73a093, 0x59ed216765690f56, + 0xe0f218b8d25088b8, 0x306869c13ec3532c, + 0x8c974f7383725573, 0x1e414218c73a13fb, + 0xafbd2350644eeacf, 0xe5d1929ef90898fa, + 0xdbac6c247d62a583, 0xdf45f746b74abf39, + 0x894bc396ce5da772, 0x6b8bba8c328eb783, + 0xab9eb47c81f5114f, 0x66ea92f3f326564, + 0xd686619ba27255a2, 0xc80a537b0efefebd, + 0x8613fd0145877585, 0xbd06742ce95f5f36, + 0xa798fc4196e952e7, 0x2c48113823b73704, + 0xd17f3b51fca3a7a0, 0xf75a15862ca504c5, + 0x82ef85133de648c4, 0x9a984d73dbe722fb, + 0xa3ab66580d5fdaf5, 0xc13e60d0d2e0ebba, + 0xcc963fee10b7d1b3, 0x318df905079926a8, + 0xffbbcfe994e5c61f, 0xfdf17746497f7052, + 0x9fd561f1fd0f9bd3, 0xfeb6ea8bedefa633, + 0xc7caba6e7c5382c8, 0xfe64a52ee96b8fc0, + 0xf9bd690a1b68637b, 0x3dfdce7aa3c673b0, + 0x9c1661a651213e2d, 0x6bea10ca65c084e, + 0xc31bfa0fe5698db8, 0x486e494fcff30a62, + 0xf3e2f893dec3f126, 0x5a89dba3c3efccfa, + 0x986ddb5c6b3a76b7, 0xf89629465a75e01c, + 0xbe89523386091465, 0xf6bbb397f1135823, + 0xee2ba6c0678b597f, 0x746aa07ded582e2c, + 0x94db483840b717ef, 0xa8c2a44eb4571cdc, + 0xba121a4650e4ddeb, 0x92f34d62616ce413, + 0xe896a0d7e51e1566, 0x77b020baf9c81d17, + 0x915e2486ef32cd60, 0xace1474dc1d122e, + 0xb5b5ada8aaff80b8, 0xd819992132456ba, + 0xe3231912d5bf60e6, 0x10e1fff697ed6c69, + 0x8df5efabc5979c8f, 0xca8d3ffa1ef463c1, + 0xb1736b96b6fd83b3, 0xbd308ff8a6b17cb2, + 0xddd0467c64bce4a0, 0xac7cb3f6d05ddbde, + 0x8aa22c0dbef60ee4, 0x6bcdf07a423aa96b, + 0xad4ab7112eb3929d, 0x86c16c98d2c953c6, + 0xd89d64d57a607744, 0xe871c7bf077ba8b7, + 0x87625f056c7c4a8b, 0x11471cd764ad4972, + 0xa93af6c6c79b5d2d, 0xd598e40d3dd89bcf, + 0xd389b47879823479, 0x4aff1d108d4ec2c3, + 0x843610cb4bf160cb, 0xcedf722a585139ba, + 0xa54394fe1eedb8fe, 0xc2974eb4ee658828, + 0xce947a3da6a9273e, 0x733d226229feea32, + 0x811ccc668829b887, 0x806357d5a3f525f, + 0xa163ff802a3426a8, 0xca07c2dcb0cf26f7, + 0xc9bcff6034c13052, 0xfc89b393dd02f0b5, + 0xfc2c3f3841f17c67, 0xbbac2078d443ace2, + 0x9d9ba7832936edc0, 0xd54b944b84aa4c0d, + 0xc5029163f384a931, 0xa9e795e65d4df11, + 0xf64335bcf065d37d, 0x4d4617b5ff4a16d5, + 0x99ea0196163fa42e, 0x504bced1bf8e4e45, + 0xc06481fb9bcf8d39, 0xe45ec2862f71e1d6, + 0xf07da27a82c37088, 0x5d767327bb4e5a4c, + 0x964e858c91ba2655, 0x3a6a07f8d510f86f, + 0xbbe226efb628afea, 0x890489f70a55368b, + 0xeadab0aba3b2dbe5, 0x2b45ac74ccea842e, + 0x92c8ae6b464fc96f, 0x3b0b8bc90012929d, + 0xb77ada0617e3bbcb, 0x9ce6ebb40173744, + 0xe55990879ddcaabd, 0xcc420a6a101d0515, + 0x8f57fa54c2a9eab6, 0x9fa946824a12232d, + 0xb32df8e9f3546564, 0x47939822dc96abf9, + 0xdff9772470297ebd, 0x59787e2b93bc56f7, + 0x8bfbea76c619ef36, 0x57eb4edb3c55b65a, + 0xaefae51477a06b03, 0xede622920b6b23f1, + 0xdab99e59958885c4, 0xe95fab368e45eced, + 0x88b402f7fd75539b, 0x11dbcb0218ebb414, + 0xaae103b5fcd2a881, 0xd652bdc29f26a119, + 0xd59944a37c0752a2, 0x4be76d3346f0495f, + 0x857fcae62d8493a5, 0x6f70a4400c562ddb, + 0xa6dfbd9fb8e5b88e, 0xcb4ccd500f6bb952, + 0xd097ad07a71f26b2, 0x7e2000a41346a7a7, + 0x825ecc24c873782f, 0x8ed400668c0c28c8, + 0xa2f67f2dfa90563b, 0x728900802f0f32fa, + 0xcbb41ef979346bca, 0x4f2b40a03ad2ffb9, + 0xfea126b7d78186bc, 0xe2f610c84987bfa8, + 0x9f24b832e6b0f436, 0xdd9ca7d2df4d7c9, + 0xc6ede63fa05d3143, 0x91503d1c79720dbb, + 0xf8a95fcf88747d94, 0x75a44c6397ce912a, + 0x9b69dbe1b548ce7c, 0xc986afbe3ee11aba, + 0xc24452da229b021b, 0xfbe85badce996168, + 0xf2d56790ab41c2a2, 0xfae27299423fb9c3, + 0x97c560ba6b0919a5, 0xdccd879fc967d41a, + 0xbdb6b8e905cb600f, 0x5400e987bbc1c920, + 0xed246723473e3813, 0x290123e9aab23b68, + 0x9436c0760c86e30b, 0xf9a0b6720aaf6521, + 0xb94470938fa89bce, 0xf808e40e8d5b3e69, + 0xe7958cb87392c2c2, 0xb60b1d1230b20e04, + 0x90bd77f3483bb9b9, 0xb1c6f22b5e6f48c2, + 0xb4ecd5f01a4aa828, 0x1e38aeb6360b1af3, + 0xe2280b6c20dd5232, 0x25c6da63c38de1b0, + 0x8d590723948a535f, 0x579c487e5a38ad0e, + 0xb0af48ec79ace837, 0x2d835a9df0c6d851, + 0xdcdb1b2798182244, 0xf8e431456cf88e65, + 0x8a08f0f8bf0f156b, 0x1b8e9ecb641b58ff, + 0xac8b2d36eed2dac5, 0xe272467e3d222f3f, + 0xd7adf884aa879177, 0x5b0ed81dcc6abb0f, + 0x86ccbb52ea94baea, 0x98e947129fc2b4e9, + 0xa87fea27a539e9a5, 0x3f2398d747b36224, + 0xd29fe4b18e88640e, 0x8eec7f0d19a03aad, + 0x83a3eeeef9153e89, 0x1953cf68300424ac, + 0xa48ceaaab75a8e2b, 0x5fa8c3423c052dd7, + 0xcdb02555653131b6, 0x3792f412cb06794d, + 0x808e17555f3ebf11, 0xe2bbd88bbee40bd0, + 0xa0b19d2ab70e6ed6, 0x5b6aceaeae9d0ec4, + 0xc8de047564d20a8b, 0xf245825a5a445275, + 0xfb158592be068d2e, 0xeed6e2f0f0d56712, + 0x9ced737bb6c4183d, 0x55464dd69685606b, + 0xc428d05aa4751e4c, 0xaa97e14c3c26b886, + 0xf53304714d9265df, 0xd53dd99f4b3066a8, + 0x993fe2c6d07b7fab, 0xe546a8038efe4029, + 0xbf8fdb78849a5f96, 0xde98520472bdd033, + 0xef73d256a5c0f77c, 0x963e66858f6d4440, + 0x95a8637627989aad, 0xdde7001379a44aa8, + 0xbb127c53b17ec159, 0x5560c018580d5d52, + 0xe9d71b689dde71af, 0xaab8f01e6e10b4a6, + 0x9226712162ab070d, 0xcab3961304ca70e8, + 0xb6b00d69bb55c8d1, 0x3d607b97c5fd0d22, + 0xe45c10c42a2b3b05, 0x8cb89a7db77c506a, + 0x8eb98a7a9a5b04e3, 0x77f3608e92adb242, + 0xb267ed1940f1c61c, 0x55f038b237591ed3, + 0xdf01e85f912e37a3, 0x6b6c46dec52f6688, + 0x8b61313bbabce2c6, 0x2323ac4b3b3da015, + 0xae397d8aa96c1b77, 0xabec975e0a0d081a, + 0xd9c7dced53c72255, 0x96e7bd358c904a21, + 0x881cea14545c7575, 0x7e50d64177da2e54, + 0xaa242499697392d2, 0xdde50bd1d5d0b9e9, + 0xd4ad2dbfc3d07787, 0x955e4ec64b44e864, + 0x84ec3c97da624ab4, 0xbd5af13bef0b113e, + 0xa6274bbdd0fadd61, 0xecb1ad8aeacdd58e, + 0xcfb11ead453994ba, 0x67de18eda5814af2, + 0x81ceb32c4b43fcf4, 0x80eacf948770ced7, + 0xa2425ff75e14fc31, 0xa1258379a94d028d, + 0xcad2f7f5359a3b3e, 0x96ee45813a04330, + 0xfd87b5f28300ca0d, 0x8bca9d6e188853fc, + 0x9e74d1b791e07e48, 0x775ea264cf55347e, + 0xc612062576589dda, 0x95364afe032a819e, + 0xf79687aed3eec551, 0x3a83ddbd83f52205, + 0x9abe14cd44753b52, 0xc4926a9672793543, + 0xc16d9a0095928a27, 0x75b7053c0f178294, + 0xf1c90080baf72cb1, 0x5324c68b12dd6339, + 0x971da05074da7bee, 0xd3f6fc16ebca5e04, + 0xbce5086492111aea, 0x88f4bb1ca6bcf585, + 0xec1e4a7db69561a5, 0x2b31e9e3d06c32e6, + 0x9392ee8e921d5d07, 0x3aff322e62439fd0, + 0xb877aa3236a4b449, 0x9befeb9fad487c3, + 0xe69594bec44de15b, 0x4c2ebe687989a9b4, + 0x901d7cf73ab0acd9, 0xf9d37014bf60a11, + 0xb424dc35095cd80f, 0x538484c19ef38c95, + 0xe12e13424bb40e13, 0x2865a5f206b06fba, + 0x8cbccc096f5088cb, 0xf93f87b7442e45d4, + 0xafebff0bcb24aafe, 0xf78f69a51539d749, + 0xdbe6fecebdedd5be, 0xb573440e5a884d1c, + 0x89705f4136b4a597, 0x31680a88f8953031, + 0xabcc77118461cefc, 0xfdc20d2b36ba7c3e, + 0xd6bf94d5e57a42bc, 0x3d32907604691b4d, + 0x8637bd05af6c69b5, 0xa63f9a49c2c1b110, + 0xa7c5ac471b478423, 0xfcf80dc33721d54, + 0xd1b71758e219652b, 0xd3c36113404ea4a9, + 0x83126e978d4fdf3b, 0x645a1cac083126ea, + 0xa3d70a3d70a3d70a, 0x3d70a3d70a3d70a4, + 0xcccccccccccccccc, 0xcccccccccccccccd, + 0x8000000000000000, 0x0, + 0xa000000000000000, 0x0, + 0xc800000000000000, 0x0, + 0xfa00000000000000, 0x0, + 0x9c40000000000000, 0x0, + 0xc350000000000000, 0x0, + 0xf424000000000000, 0x0, + 0x9896800000000000, 0x0, + 0xbebc200000000000, 0x0, + 0xee6b280000000000, 0x0, + 0x9502f90000000000, 0x0, + 0xba43b74000000000, 0x0, + 0xe8d4a51000000000, 0x0, + 0x9184e72a00000000, 0x0, + 0xb5e620f480000000, 0x0, + 0xe35fa931a0000000, 0x0, + 0x8e1bc9bf04000000, 0x0, + 0xb1a2bc2ec5000000, 0x0, + 0xde0b6b3a76400000, 0x0, + 0x8ac7230489e80000, 0x0, + 0xad78ebc5ac620000, 0x0, + 0xd8d726b7177a8000, 0x0, + 0x878678326eac9000, 0x0, + 0xa968163f0a57b400, 0x0, + 0xd3c21bcecceda100, 0x0, + 0x84595161401484a0, 0x0, + 0xa56fa5b99019a5c8, 0x0, + 0xcecb8f27f4200f3a, 0x0, + 0x813f3978f8940984, 0x4000000000000000, + 0xa18f07d736b90be5, 0x5000000000000000, + 0xc9f2c9cd04674ede, 0xa400000000000000, + 0xfc6f7c4045812296, 0x4d00000000000000, + 0x9dc5ada82b70b59d, 0xf020000000000000, + 0xc5371912364ce305, 0x6c28000000000000, + 0xf684df56c3e01bc6, 0xc732000000000000, + 0x9a130b963a6c115c, 0x3c7f400000000000, + 0xc097ce7bc90715b3, 0x4b9f100000000000, + 0xf0bdc21abb48db20, 0x1e86d40000000000, + 0x96769950b50d88f4, 0x1314448000000000, + 0xbc143fa4e250eb31, 0x17d955a000000000, + 0xeb194f8e1ae525fd, 0x5dcfab0800000000, + 0x92efd1b8d0cf37be, 0x5aa1cae500000000, + 0xb7abc627050305ad, 0xf14a3d9e40000000, + 0xe596b7b0c643c719, 0x6d9ccd05d0000000, + 0x8f7e32ce7bea5c6f, 0xe4820023a2000000, + 0xb35dbf821ae4f38b, 0xdda2802c8a800000, + 0xe0352f62a19e306e, 0xd50b2037ad200000, + 0x8c213d9da502de45, 0x4526f422cc340000, + 0xaf298d050e4395d6, 0x9670b12b7f410000, + 0xdaf3f04651d47b4c, 0x3c0cdd765f114000, + 0x88d8762bf324cd0f, 0xa5880a69fb6ac800, + 0xab0e93b6efee0053, 0x8eea0d047a457a00, + 0xd5d238a4abe98068, 0x72a4904598d6d880, + 0x85a36366eb71f041, 0x47a6da2b7f864750, + 0xa70c3c40a64e6c51, 0x999090b65f67d924, + 0xd0cf4b50cfe20765, 0xfff4b4e3f741cf6d, + 0x82818f1281ed449f, 0xbff8f10e7a8921a4, + 0xa321f2d7226895c7, 0xaff72d52192b6a0d, + 0xcbea6f8ceb02bb39, 0x9bf4f8a69f764490, + 0xfee50b7025c36a08, 0x2f236d04753d5b4, + 0x9f4f2726179a2245, 0x1d762422c946590, + 0xc722f0ef9d80aad6, 0x424d3ad2b7b97ef5, + 0xf8ebad2b84e0d58b, 0xd2e0898765a7deb2, + 0x9b934c3b330c8577, 0x63cc55f49f88eb2f, + 0xc2781f49ffcfa6d5, 0x3cbf6b71c76b25fb, + 0xf316271c7fc3908a, 0x8bef464e3945ef7a, + 0x97edd871cfda3a56, 0x97758bf0e3cbb5ac, + 0xbde94e8e43d0c8ec, 0x3d52eeed1cbea317, + 0xed63a231d4c4fb27, 0x4ca7aaa863ee4bdd, + 0x945e455f24fb1cf8, 0x8fe8caa93e74ef6a, + 0xb975d6b6ee39e436, 0xb3e2fd538e122b44, + 0xe7d34c64a9c85d44, 0x60dbbca87196b616, + 0x90e40fbeea1d3a4a, 0xbc8955e946fe31cd, + 0xb51d13aea4a488dd, 0x6babab6398bdbe41, + 0xe264589a4dcdab14, 0xc696963c7eed2dd1, + 0x8d7eb76070a08aec, 0xfc1e1de5cf543ca2, + 0xb0de65388cc8ada8, 0x3b25a55f43294bcb, + 0xdd15fe86affad912, 0x49ef0eb713f39ebe, + 0x8a2dbf142dfcc7ab, 0x6e3569326c784337, + 0xacb92ed9397bf996, 0x49c2c37f07965404, + 0xd7e77a8f87daf7fb, 0xdc33745ec97be906, + 0x86f0ac99b4e8dafd, 0x69a028bb3ded71a3, + 0xa8acd7c0222311bc, 0xc40832ea0d68ce0c, + 0xd2d80db02aabd62b, 0xf50a3fa490c30190, + 0x83c7088e1aab65db, 0x792667c6da79e0fa, + 0xa4b8cab1a1563f52, 0x577001b891185938, + 0xcde6fd5e09abcf26, 0xed4c0226b55e6f86, + 0x80b05e5ac60b6178, 0x544f8158315b05b4, + 0xa0dc75f1778e39d6, 0x696361ae3db1c721, + 0xc913936dd571c84c, 0x3bc3a19cd1e38e9, + 0xfb5878494ace3a5f, 0x4ab48a04065c723, + 0x9d174b2dcec0e47b, 0x62eb0d64283f9c76, + 0xc45d1df942711d9a, 0x3ba5d0bd324f8394, + 0xf5746577930d6500, 0xca8f44ec7ee36479, + 0x9968bf6abbe85f20, 0x7e998b13cf4e1ecb, + 0xbfc2ef456ae276e8, 0x9e3fedd8c321a67e, + 0xefb3ab16c59b14a2, 0xc5cfe94ef3ea101e, + 0x95d04aee3b80ece5, 0xbba1f1d158724a12, + 0xbb445da9ca61281f, 0x2a8a6e45ae8edc97, + 0xea1575143cf97226, 0xf52d09d71a3293bd, + 0x924d692ca61be758, 0x593c2626705f9c56, + 0xb6e0c377cfa2e12e, 0x6f8b2fb00c77836c, + 0xe498f455c38b997a, 0xb6dfb9c0f956447, + 0x8edf98b59a373fec, 0x4724bd4189bd5eac, + 0xb2977ee300c50fe7, 0x58edec91ec2cb657, + 0xdf3d5e9bc0f653e1, 0x2f2967b66737e3ed, + 0x8b865b215899f46c, 0xbd79e0d20082ee74, + 0xae67f1e9aec07187, 0xecd8590680a3aa11, + 0xda01ee641a708de9, 0xe80e6f4820cc9495, + 0x884134fe908658b2, 0x3109058d147fdcdd, + 0xaa51823e34a7eede, 0xbd4b46f0599fd415, + 0xd4e5e2cdc1d1ea96, 0x6c9e18ac7007c91a, + 0x850fadc09923329e, 0x3e2cf6bc604ddb0, + 0xa6539930bf6bff45, 0x84db8346b786151c, + 0xcfe87f7cef46ff16, 0xe612641865679a63, + 0x81f14fae158c5f6e, 0x4fcb7e8f3f60c07e, + 0xa26da3999aef7749, 0xe3be5e330f38f09d, + 0xcb090c8001ab551c, 0x5cadf5bfd3072cc5, + 0xfdcb4fa002162a63, 0x73d9732fc7c8f7f6, + 0x9e9f11c4014dda7e, 0x2867e7fddcdd9afa, + 0xc646d63501a1511d, 0xb281e1fd541501b8, + 0xf7d88bc24209a565, 0x1f225a7ca91a4226, + 0x9ae757596946075f, 0x3375788de9b06958, + 0xc1a12d2fc3978937, 0x52d6b1641c83ae, + 0xf209787bb47d6b84, 0xc0678c5dbd23a49a, + 0x9745eb4d50ce6332, 0xf840b7ba963646e0, + 0xbd176620a501fbff, 0xb650e5a93bc3d898, + 0xec5d3fa8ce427aff, 0xa3e51f138ab4cebe, + 0x93ba47c980e98cdf, 0xc66f336c36b10137, + 0xb8a8d9bbe123f017, 0xb80b0047445d4184, + 0xe6d3102ad96cec1d, 0xa60dc059157491e5, + 0x9043ea1ac7e41392, 0x87c89837ad68db2f, + 0xb454e4a179dd1877, 0x29babe4598c311fb, + 0xe16a1dc9d8545e94, 0xf4296dd6fef3d67a, + 0x8ce2529e2734bb1d, 0x1899e4a65f58660c, + 0xb01ae745b101e9e4, 0x5ec05dcff72e7f8f, + 0xdc21a1171d42645d, 0x76707543f4fa1f73, + 0x899504ae72497eba, 0x6a06494a791c53a8, + 0xabfa45da0edbde69, 0x487db9d17636892, + 0xd6f8d7509292d603, 0x45a9d2845d3c42b6, + 0x865b86925b9bc5c2, 0xb8a2392ba45a9b2, + 0xa7f26836f282b732, 0x8e6cac7768d7141e, + 0xd1ef0244af2364ff, 0x3207d795430cd926, + 0x8335616aed761f1f, 0x7f44e6bd49e807b8, + 0xa402b9c5a8d3a6e7, 0x5f16206c9c6209a6, + 0xcd036837130890a1, 0x36dba887c37a8c0f, + 0x802221226be55a64, 0xc2494954da2c9789, + 0xa02aa96b06deb0fd, 0xf2db9baa10b7bd6c, + 0xc83553c5c8965d3d, 0x6f92829494e5acc7, + 0xfa42a8b73abbf48c, 0xcb772339ba1f17f9, + 0x9c69a97284b578d7, 0xff2a760414536efb, + 0xc38413cf25e2d70d, 0xfef5138519684aba, + 0xf46518c2ef5b8cd1, 0x7eb258665fc25d69, + 0x98bf2f79d5993802, 0xef2f773ffbd97a61, + 0xbeeefb584aff8603, 0xaafb550ffacfd8fa, + 0xeeaaba2e5dbf6784, 0x95ba2a53f983cf38, + 0x952ab45cfa97a0b2, 0xdd945a747bf26183, + 0xba756174393d88df, 0x94f971119aeef9e4, + 0xe912b9d1478ceb17, 0x7a37cd5601aab85d, + 0x91abb422ccb812ee, 0xac62e055c10ab33a, + 0xb616a12b7fe617aa, 0x577b986b314d6009, + 0xe39c49765fdf9d94, 0xed5a7e85fda0b80b, + 0x8e41ade9fbebc27d, 0x14588f13be847307, + 0xb1d219647ae6b31c, 0x596eb2d8ae258fc8, + 0xde469fbd99a05fe3, 0x6fca5f8ed9aef3bb, + 0x8aec23d680043bee, 0x25de7bb9480d5854, + 0xada72ccc20054ae9, 0xaf561aa79a10ae6a, + 0xd910f7ff28069da4, 0x1b2ba1518094da04, + 0x87aa9aff79042286, 0x90fb44d2f05d0842, + 0xa99541bf57452b28, 0x353a1607ac744a53, + 0xd3fa922f2d1675f2, 0x42889b8997915ce8, + 0x847c9b5d7c2e09b7, 0x69956135febada11, + 0xa59bc234db398c25, 0x43fab9837e699095, + 0xcf02b2c21207ef2e, 0x94f967e45e03f4bb, + 0x8161afb94b44f57d, 0x1d1be0eebac278f5, + 0xa1ba1ba79e1632dc, 0x6462d92a69731732, + 0xca28a291859bbf93, 0x7d7b8f7503cfdcfe, + 0xfcb2cb35e702af78, 0x5cda735244c3d43e, + 0x9defbf01b061adab, 0x3a0888136afa64a7, + 0xc56baec21c7a1916, 0x88aaa1845b8fdd0, + 0xf6c69a72a3989f5b, 0x8aad549e57273d45, + 0x9a3c2087a63f6399, 0x36ac54e2f678864b, + 0xc0cb28a98fcf3c7f, 0x84576a1bb416a7dd, + 0xf0fdf2d3f3c30b9f, 0x656d44a2a11c51d5, + 0x969eb7c47859e743, 0x9f644ae5a4b1b325, + 0xbc4665b596706114, 0x873d5d9f0dde1fee, + 0xeb57ff22fc0c7959, 0xa90cb506d155a7ea, + 0x9316ff75dd87cbd8, 0x9a7f12442d588f2, + 0xb7dcbf5354e9bece, 0xc11ed6d538aeb2f, + 0xe5d3ef282a242e81, 0x8f1668c8a86da5fa, + 0x8fa475791a569d10, 0xf96e017d694487bc, + 0xb38d92d760ec4455, 0x37c981dcc395a9ac, + 0xe070f78d3927556a, 0x85bbe253f47b1417, + 0x8c469ab843b89562, 0x93956d7478ccec8e, + 0xaf58416654a6babb, 0x387ac8d1970027b2, + 0xdb2e51bfe9d0696a, 0x6997b05fcc0319e, + 0x88fcf317f22241e2, 0x441fece3bdf81f03, + 0xab3c2fddeeaad25a, 0xd527e81cad7626c3, + 0xd60b3bd56a5586f1, 0x8a71e223d8d3b074, + 0x85c7056562757456, 0xf6872d5667844e49, + 0xa738c6bebb12d16c, 0xb428f8ac016561db, + 0xd106f86e69d785c7, 0xe13336d701beba52, + 0x82a45b450226b39c, 0xecc0024661173473, + 0xa34d721642b06084, 0x27f002d7f95d0190, + 0xcc20ce9bd35c78a5, 0x31ec038df7b441f4, + 0xff290242c83396ce, 0x7e67047175a15271, + 0x9f79a169bd203e41, 0xf0062c6e984d386, + 0xc75809c42c684dd1, 0x52c07b78a3e60868, + 0xf92e0c3537826145, 0xa7709a56ccdf8a82, + 0x9bbcc7a142b17ccb, 0x88a66076400bb691, + 0xc2abf989935ddbfe, 0x6acff893d00ea435, + 0xf356f7ebf83552fe, 0x583f6b8c4124d43, + 0x98165af37b2153de, 0xc3727a337a8b704a, + 0xbe1bf1b059e9a8d6, 0x744f18c0592e4c5c, + 0xeda2ee1c7064130c, 0x1162def06f79df73, + 0x9485d4d1c63e8be7, 0x8addcb5645ac2ba8, + 0xb9a74a0637ce2ee1, 0x6d953e2bd7173692, + 0xe8111c87c5c1ba99, 0xc8fa8db6ccdd0437, + 0x910ab1d4db9914a0, 0x1d9c9892400a22a2, + 0xb54d5e4a127f59c8, 0x2503beb6d00cab4b, + 0xe2a0b5dc971f303a, 0x2e44ae64840fd61d, + 0x8da471a9de737e24, 0x5ceaecfed289e5d2, + 0xb10d8e1456105dad, 0x7425a83e872c5f47, + 0xdd50f1996b947518, 0xd12f124e28f77719, + 0x8a5296ffe33cc92f, 0x82bd6b70d99aaa6f, + 0xace73cbfdc0bfb7b, 0x636cc64d1001550b, + 0xd8210befd30efa5a, 0x3c47f7e05401aa4e, + 0x8714a775e3e95c78, 0x65acfaec34810a71, + 0xa8d9d1535ce3b396, 0x7f1839a741a14d0d, + 0xd31045a8341ca07c, 0x1ede48111209a050, + 0x83ea2b892091e44d, 0x934aed0aab460432, + 0xa4e4b66b68b65d60, 0xf81da84d5617853f, + 0xce1de40642e3f4b9, 0x36251260ab9d668e, + 0x80d2ae83e9ce78f3, 0xc1d72b7c6b426019, + 0xa1075a24e4421730, 0xb24cf65b8612f81f, + 0xc94930ae1d529cfc, 0xdee033f26797b627, + 0xfb9b7cd9a4a7443c, 0x169840ef017da3b1, + 0x9d412e0806e88aa5, 0x8e1f289560ee864e, + 0xc491798a08a2ad4e, 0xf1a6f2bab92a27e2, + 0xf5b5d7ec8acb58a2, 0xae10af696774b1db, + 0x9991a6f3d6bf1765, 0xacca6da1e0a8ef29, + 0xbff610b0cc6edd3f, 0x17fd090a58d32af3, + 0xeff394dcff8a948e, 0xddfc4b4cef07f5b0, + 0x95f83d0a1fb69cd9, 0x4abdaf101564f98e, + 0xbb764c4ca7a4440f, 0x9d6d1ad41abe37f1, + 0xea53df5fd18d5513, 0x84c86189216dc5ed, + 0x92746b9be2f8552c, 0x32fd3cf5b4e49bb4, + 0xb7118682dbb66a77, 0x3fbc8c33221dc2a1, + 0xe4d5e82392a40515, 0xfabaf3feaa5334a, + 0x8f05b1163ba6832d, 0x29cb4d87f2a7400e, + 0xb2c71d5bca9023f8, 0x743e20e9ef511012, + 0xdf78e4b2bd342cf6, 0x914da9246b255416, + 0x8bab8eefb6409c1a, 0x1ad089b6c2f7548e, + 0xae9672aba3d0c320, 0xa184ac2473b529b1, + 0xda3c0f568cc4f3e8, 0xc9e5d72d90a2741e, + 0x8865899617fb1871, 0x7e2fa67c7a658892, + 0xaa7eebfb9df9de8d, 0xddbb901b98feeab7, + 0xd51ea6fa85785631, 0x552a74227f3ea565, + 0x8533285c936b35de, 0xd53a88958f87275f, + 0xa67ff273b8460356, 0x8a892abaf368f137, + 0xd01fef10a657842c, 0x2d2b7569b0432d85, + 0x8213f56a67f6b29b, 0x9c3b29620e29fc73, + 0xa298f2c501f45f42, 0x8349f3ba91b47b8f, + 0xcb3f2f7642717713, 0x241c70a936219a73, + 0xfe0efb53d30dd4d7, 0xed238cd383aa0110, + 0x9ec95d1463e8a506, 0xf4363804324a40aa, + 0xc67bb4597ce2ce48, 0xb143c6053edcd0d5, + 0xf81aa16fdc1b81da, 0xdd94b7868e94050a, + 0x9b10a4e5e9913128, 0xca7cf2b4191c8326, + 0xc1d4ce1f63f57d72, 0xfd1c2f611f63a3f0, + 0xf24a01a73cf2dccf, 0xbc633b39673c8cec, + 0x976e41088617ca01, 0xd5be0503e085d813, + 0xbd49d14aa79dbc82, 0x4b2d8644d8a74e18, + 0xec9c459d51852ba2, 0xddf8e7d60ed1219e, + 0x93e1ab8252f33b45, 0xcabb90e5c942b503, + 0xb8da1662e7b00a17, 0x3d6a751f3b936243, + 0xe7109bfba19c0c9d, 0xcc512670a783ad4, + 0x906a617d450187e2, 0x27fb2b80668b24c5, + 0xb484f9dc9641e9da, 0xb1f9f660802dedf6, + 0xe1a63853bbd26451, 0x5e7873f8a0396973, + 0x8d07e33455637eb2, 0xdb0b487b6423e1e8, + 0xb049dc016abc5e5f, 0x91ce1a9a3d2cda62, + 0xdc5c5301c56b75f7, 0x7641a140cc7810fb, + 0x89b9b3e11b6329ba, 0xa9e904c87fcb0a9d, + 0xac2820d9623bf429, 0x546345fa9fbdcd44, + 0xd732290fbacaf133, 0xa97c177947ad4095, + 0x867f59a9d4bed6c0, 0x49ed8eabcccc485d, + 0xa81f301449ee8c70, 0x5c68f256bfff5a74, + 0xd226fc195c6a2f8c, 0x73832eec6fff3111, + 0x83585d8fd9c25db7, 0xc831fd53c5ff7eab, + 0xa42e74f3d032f525, 0xba3e7ca8b77f5e55, + 0xcd3a1230c43fb26f, 0x28ce1bd2e55f35eb, + 0x80444b5e7aa7cf85, 0x7980d163cf5b81b3, + 0xa0555e361951c366, 0xd7e105bcc332621f, + 0xc86ab5c39fa63440, 0x8dd9472bf3fefaa7, + 0xfa856334878fc150, 0xb14f98f6f0feb951, + 0x9c935e00d4b9d8d2, 0x6ed1bf9a569f33d3, + 0xc3b8358109e84f07, 0xa862f80ec4700c8, + 0xf4a642e14c6262c8, 0xcd27bb612758c0fa, + 0x98e7e9cccfbd7dbd, 0x8038d51cb897789c, + 0xbf21e44003acdd2c, 0xe0470a63e6bd56c3, + 0xeeea5d5004981478, 0x1858ccfce06cac74, + 0x95527a5202df0ccb, 0xf37801e0c43ebc8, + 0xbaa718e68396cffd, 0xd30560258f54e6ba, + 0xe950df20247c83fd, 0x47c6b82ef32a2069, + 0x91d28b7416cdd27e, 0x4cdc331d57fa5441, + 0xb6472e511c81471d, 0xe0133fe4adf8e952, + 0xe3d8f9e563a198e5, 0x58180fddd97723a6, + 0x8e679c2f5e44ff8f, 0x570f09eaa7ea7648, +}; + +/* binary_format constants from fast_float. */ +#define FFP_MANTISSA_BITS 52 +#define FFP_MIN_EXPONENT (-1023) +#define FFP_INFINITE_POWER 0x7FF +#define FFP_SMALLEST_POW10 (-342) +#define FFP_LARGEST_POW10 308 +#define FFP_MIN_RTE (-4) /* min_exponent_round_to_even */ +#define FFP_MAX_RTE 23 /* max_exponent_round_to_even */ + +/* (((152170 + 65536) * q) >> 16) + 63 == floor(log2(10^q)) + q + 63, see paper. */ +static inline int32_t ffp_power(int32_t q) { + return (((152170 + 65536) * q) >> 16) + 63; +} + +static inline void ffp_mul128(uint64_t a, uint64_t b, uint64_t *hi, uint64_t *lo) { +#if defined(__SIZEOF_INT128__) + __uint128_t p = (__uint128_t)a * (__uint128_t)b; + *lo = (uint64_t)p; + *hi = (uint64_t)(p >> 64); +#else + uint64_t a0 = (uint32_t)a, a1 = a >> 32, b0 = (uint32_t)b, b1 = b >> 32; + uint64_t p00 = a0 * b0, p01 = a0 * b1, p10 = a1 * b0, p11 = a1 * b1; + uint64_t mid = p10 + (p00 >> 32) + (uint32_t)p01; + *hi = p11 + (mid >> 32) + (p01 >> 32); + *lo = (mid << 32) | (uint32_t)p00; +#endif +} + +static inline double ffp_bits2double(uint64_t bits) { + double d; + memcpy(&d, &bits, sizeof(d)); + return d; +} + +static inline unsigned int +ffc_nlz_int64(uint64_t x) +{ +#if defined(_MSC_VER) && defined(__AVX2__) + return (unsigned int)__lzcnt64(x); + +#elif defined(__x86_64__) && defined(__LZCNT__) + return (unsigned int)_lzcnt_u64(x); + +#elif defined(_WIN64) && defined(_MSC_VER) /* &&! defined(__AVX2__) */ + unsigned long r; + return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64; + +#elif __has_builtin(__builtin_clzll) + return (unsigned int)__builtin_clzll((unsigned long long)x); + +#else + uint64_t y; + unsigned int n = 64; + y = x >> 32; if (y) {n -= 32; x = y;} + y = x >> 16; if (y) {n -= 16; x = y;} + y = x >> 8; if (y) {n -= 8; x = y;} + y = x >> 4; if (y) {n -= 4; x = y;} + y = x >> 2; if (y) {n -= 2; x = y;} + y = x >> 1; if (y) {return n - 2;} + return (unsigned int)(n - x); + +#endif +} + +/* q = power of ten, w = mantissa (exact, fits in uint64). neg = sign. */ +static inline double ffp_s2d(int64_t q, uint64_t w, bool neg) { + if (w == 0) { + return neg ? -0.0 : 0.0; + } + + const uint64_t sign = (uint64_t)(neg != 0) << 63; + uint64_t mantissa, prod_hi, prod_lo, sp_hi, sp_lo; + int32_t power2; + int upperbit, shift, index; + + if (q < FFP_SMALLEST_POW10) return ffp_bits2double(sign); /* underflow -> 0 */ + if (q > FFP_LARGEST_POW10) { + return ffp_bits2double(sign | ((uint64_t)FFP_INFINITE_POWER << FFP_MANTISSA_BITS)); + } + + unsigned int lz = ffc_nlz_int64(w); + w <<= lz; + + /* compute_product_approximation: precision_mask = 0x1FF. */ + index = 2 * (int)(q - FFP_SMALLEST_POWER_OF_FIVE); + ffp_mul128(w, ffp_power_of_five_128[index], &prod_hi, &prod_lo); + if ((prod_hi & 0x1FF) == 0x1FF) { + ffp_mul128(w, ffp_power_of_five_128[index + 1], &sp_hi, &sp_lo); + prod_lo += sp_hi; + if (sp_hi > prod_lo) { + prod_hi++; + } + } + + upperbit = (int)(prod_hi >> 63); + shift = upperbit + 64 - FFP_MANTISSA_BITS - 3; /* upperbit + 9 */ + mantissa = prod_hi >> shift; + power2 = (int32_t)(ffp_power((int32_t)q) + upperbit - lz - FFP_MIN_EXPONENT); + + if (power2 <= 0) { /* subnormal */ + if (-power2 + 1 >= 64) return ffp_bits2double(sign); /* far below min -> 0 */ + mantissa >>= (-power2 + 1); + mantissa += (mantissa & 1); + mantissa >>= 1; + power2 = (mantissa < ((uint64_t)1 << FFP_MANTISSA_BITS)) ? 0 : 1; + return ffp_bits2double(sign | ((uint64_t)power2 << FFP_MANTISSA_BITS) | mantissa); + } + + /* round-to-even: if we land exactly between two doubles, round down. */ + if ((prod_lo <= 1) && (q >= FFP_MIN_RTE) && (q <= FFP_MAX_RTE) && + ((mantissa & 3) == 1) && ((mantissa << shift) == prod_hi)) { + mantissa &= ~(uint64_t)1; + } + + mantissa += (mantissa & 1); + mantissa >>= 1; + if (mantissa >= ((uint64_t)2 << FFP_MANTISSA_BITS)) { + mantissa = (uint64_t)1 << FFP_MANTISSA_BITS; + power2++; + } + + mantissa &= ~((uint64_t)1 << FFP_MANTISSA_BITS); /* drop implicit bit */ + if (power2 >= FFP_INFINITE_POWER) { + return ffp_bits2double(sign | ((uint64_t)FFP_INFINITE_POWER << FFP_MANTISSA_BITS)); + } + return ffp_bits2double(sign | ((uint64_t)power2 << FFP_MANTISSA_BITS) | mantissa); +} + +#endif // FFP_H diff --git a/ext/json/ext/vendor/ryu.h b/ext/json/ext/vendor/ryu.h deleted file mode 100644 index f06ec814..00000000 --- a/ext/json/ext/vendor/ryu.h +++ /dev/null @@ -1,819 +0,0 @@ -// Copyright 2018 Ulf Adams -// -// The contents of this file may be used under the terms of the Apache License, -// Version 2.0. -// -// Alternatively, the contents of this file may be used under the terms of -// the Boost Software License, Version 1.0. -// -// Unless required by applicable law or agreed to in writing, this software -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. -// -// --- -// -// Apache License -// Version 2.0, January 2004 -// http://www.apache.org/licenses/ -// -// TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -// -// 1. Definitions. -// -// "License" shall mean the terms and conditions for use, reproduction, -// and distribution as defined by Sections 1 through 9 of this document. -// -// "Licensor" shall mean the copyright owner or entity authorized by -// the copyright owner that is granting the License. -// -// "Legal Entity" shall mean the union of the acting entity and all -// other entities that control, are controlled by, or are under common -// control with that entity. For the purposes of this definition, -// "control" means (i) the power, direct or indirect, to cause the -// direction or management of such entity, whether by contract or -// otherwise, or (ii) ownership of fifty percent (50%) or more of the -// outstanding shares, or (iii) beneficial ownership of such entity. -// -// "You" (or "Your") shall mean an individual or Legal Entity -// exercising permissions granted by this License. -// -// "Source" form shall mean the preferred form for making modifications, -// including but not limited to software source code, documentation -// source, and configuration files. -// -// "Object" form shall mean any form resulting from mechanical -// transformation or translation of a Source form, including but -// not limited to compiled object code, generated documentation, -// and conversions to other media types. -// -// "Work" shall mean the work of authorship, whether in Source or -// Object form, made available under the License, as indicated by a -// copyright notice that is included in or attached to the work -// (an example is provided in the Appendix below). -// -// "Derivative Works" shall mean any work, whether in Source or Object -// form, that is based on (or derived from) the Work and for which the -// editorial revisions, annotations, elaborations, or other modifications -// represent, as a whole, an original work of authorship. For the purposes -// of this License, Derivative Works shall not include works that remain -// separable from, or merely link (or bind by name) to the interfaces of, -// the Work and Derivative Works thereof. -// -// "Contribution" shall mean any work of authorship, including -// the original version of the Work and any modifications or additions -// to that Work or Derivative Works thereof, that is intentionally -// submitted to Licensor for inclusion in the Work by the copyright owner -// or by an individual or Legal Entity authorized to submit on behalf of -// the copyright owner. For the purposes of this definition, "submitted" -// means any form of electronic, verbal, or written communication sent -// to the Licensor or its representatives, including but not limited to -// communication on electronic mailing lists, source code control systems, -// and issue tracking systems that are managed by, or on behalf of, the -// Licensor for the purpose of discussing and improving the Work, but -// excluding communication that is conspicuously marked or otherwise -// designated in writing by the copyright owner as "Not a Contribution." -// -// "Contributor" shall mean Licensor and any individual or Legal Entity -// on behalf of whom a Contribution has been received by Licensor and -// subsequently incorporated within the Work. -// -// 2. Grant of Copyright License. Subject to the terms and conditions of -// this License, each Contributor hereby grants to You a perpetual, -// worldwide, non-exclusive, no-charge, royalty-free, irrevocable -// copyright license to reproduce, prepare Derivative Works of, -// publicly display, publicly perform, sublicense, and distribute the -// Work and such Derivative Works in Source or Object form. -// -// 3. Grant of Patent License. Subject to the terms and conditions of -// this License, each Contributor hereby grants to You a perpetual, -// worldwide, non-exclusive, no-charge, royalty-free, irrevocable -// (except as stated in this section) patent license to make, have made, -// use, offer to sell, sell, import, and otherwise transfer the Work, -// where such license applies only to those patent claims licensable -// by such Contributor that are necessarily infringed by their -// Contribution(s) alone or by combination of their Contribution(s) -// with the Work to which such Contribution(s) was submitted. If You -// institute patent litigation against any entity (including a -// cross-claim or counterclaim in a lawsuit) alleging that the Work -// or a Contribution incorporated within the Work constitutes direct -// or contributory patent infringement, then any patent licenses -// granted to You under this License for that Work shall terminate -// as of the date such litigation is filed. -// -// 4. Redistribution. You may reproduce and distribute copies of the -// Work or Derivative Works thereof in any medium, with or without -// modifications, and in Source or Object form, provided that You -// meet the following conditions: -// -// (a) You must give any other recipients of the Work or -// Derivative Works a copy of this License; and -// -// (b) You must cause any modified files to carry prominent notices -// stating that You changed the files; and -// -// (c) You must retain, in the Source form of any Derivative Works -// that You distribute, all copyright, patent, trademark, and -// attribution notices from the Source form of the Work, -// excluding those notices that do not pertain to any part of -// the Derivative Works; and -// -// (d) If the Work includes a "NOTICE" text file as part of its -// distribution, then any Derivative Works that You distribute must -// include a readable copy of the attribution notices contained -// within such NOTICE file, excluding those notices that do not -// pertain to any part of the Derivative Works, in at least one -// of the following places: within a NOTICE text file distributed -// as part of the Derivative Works; within the Source form or -// documentation, if provided along with the Derivative Works; or, -// within a display generated by the Derivative Works, if and -// wherever such third-party notices normally appear. The contents -// of the NOTICE file are for informational purposes only and -// do not modify the License. You may add Your own attribution -// notices within Derivative Works that You distribute, alongside -// or as an addendum to the NOTICE text from the Work, provided -// that such additional attribution notices cannot be construed -// as modifying the License. -// -// You may add Your own copyright statement to Your modifications and -// may provide additional or different license terms and conditions -// for use, reproduction, or distribution of Your modifications, or -// for any such Derivative Works as a whole, provided Your use, -// reproduction, and distribution of the Work otherwise complies with -// the conditions stated in this License. -// -// 5. Submission of Contributions. Unless You explicitly state otherwise, -// any Contribution intentionally submitted for inclusion in the Work -// by You to the Licensor shall be under the terms and conditions of -// this License, without any additional terms or conditions. -// Notwithstanding the above, nothing herein shall supersede or modify -// the terms of any separate license agreement you may have executed -// with Licensor regarding such Contributions. -// -// 6. Trademarks. This License does not grant permission to use the trade -// names, trademarks, service marks, or product names of the Licensor, -// except as required for reasonable and customary use in describing the -// origin of the Work and reproducing the content of the NOTICE file. -// -// 7. Disclaimer of Warranty. Unless required by applicable law or -// agreed to in writing, Licensor provides the Work (and each -// Contributor provides its Contributions) on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -// implied, including, without limitation, any warranties or conditions -// of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A -// PARTICULAR PURPOSE. You are solely responsible for determining the -// appropriateness of using or redistributing the Work and assume any -// risks associated with Your exercise of permissions under this License. -// -// 8. Limitation of Liability. In no event and under no legal theory, -// whether in tort (including negligence), contract, or otherwise, -// unless required by applicable law (such as deliberate and grossly -// negligent acts) or agreed to in writing, shall any Contributor be -// liable to You for damages, including any direct, indirect, special, -// incidental, or consequential damages of any character arising as a -// result of this License or out of the use or inability to use the -// Work (including but not limited to damages for loss of goodwill, -// work stoppage, computer failure or malfunction, or any and all -// other commercial damages or losses), even if such Contributor -// has been advised of the possibility of such damages. -// -// 9. Accepting Warranty or Additional Liability. While redistributing -// the Work or Derivative Works thereof, You may choose to offer, -// and charge a fee for, acceptance of support, warranty, indemnity, -// or other liability obligations and/or rights consistent with this -// License. However, in accepting such obligations, You may act only -// on Your own behalf and on Your sole responsibility, not on behalf -// of any other Contributor, and only if You agree to indemnify, -// defend, and hold each Contributor harmless for any liability -// incurred by, or claims asserted against, such Contributor by reason -// of your accepting any such warranty or additional liability. -// -// END OF TERMS AND CONDITIONS -// -// APPENDIX: How to apply the Apache License to your work. -// -// To apply the Apache License to your work, attach the following -// boilerplate notice, with the fields enclosed by brackets "[]" -// replaced with your own identifying information. (Don't include -// the brackets!) The text should be enclosed in the appropriate -// comment syntax for the file format. We also recommend that a -// file or class name and description of purpose be included on the -// same "printed page" as the copyright notice for easier -// identification within third-party archives. -// -// Copyright [yyyy] [name of copyright owner] -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// --- -// -// Boost Software License - Version 1.0 - August 17th, 2003 -// -// Permission is hereby granted, free of charge, to any person or organization -// obtaining a copy of the software and accompanying documentation covered by -// this license (the "Software") to use, reproduce, display, distribute, -// execute, and transmit the Software, and to prepare derivative works of the -// Software, and to permit third-parties to whom the Software is furnished to -// do so, all subject to the following: -// -// The copyright notices in the Software and this entire statement, including -// the above license grant, this restriction and the following disclaimer, -// must be included in all copies of the Software, in whole or in part, and -// all derivative works of the Software, unless such copies or derivative -// works are solely in the form of machine-executable object code generated by -// a source language processor. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// --- -// Minimal Ryu implementation adapted for Ruby JSON gem by Josef Šimánek -// Optimized for pre-extracted mantissa/exponent from JSON parsing -// This is a stripped-down version containing only what's needed for -// converting decimal mantissa+exponent to IEEE 754 double precision. - -#ifndef RYU_H -#define RYU_H - -#include -#include -#include - -// Detect __builtin_clzll availability (for floor_log2) -// Note: MSVC doesn't have __builtin_clzll, so we provide a fallback -#ifdef __clang__ - #if __has_builtin(__builtin_clzll) - #define RYU_HAVE_BUILTIN_CLZLL 1 - #else - #define RYU_HAVE_BUILTIN_CLZLL 0 - #endif -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - #define RYU_HAVE_BUILTIN_CLZLL 1 -#else - #define RYU_HAVE_BUILTIN_CLZLL 0 -#endif - -// Count leading zeros (for floor_log2) -static inline uint32_t ryu_leading_zeros64(uint64_t input) -{ -#if RYU_HAVE_BUILTIN_CLZLL - return __builtin_clzll(input); -#else - // Fallback: binary search for the highest set bit - // This works on MSVC and other compilers without __builtin_clzll - if (input == 0) return 64; - uint32_t n = 0; - if (input <= 0x00000000FFFFFFFFULL) { n += 32; input <<= 32; } - if (input <= 0x0000FFFFFFFFFFFFULL) { n += 16; input <<= 16; } - if (input <= 0x00FFFFFFFFFFFFFFULL) { n += 8; input <<= 8; } - if (input <= 0x0FFFFFFFFFFFFFFFULL) { n += 4; input <<= 4; } - if (input <= 0x3FFFFFFFFFFFFFFFULL) { n += 2; input <<= 2; } - if (input <= 0x7FFFFFFFFFFFFFFFULL) { n += 1; } - return n; -#endif -} - -// These tables are generated by PrintDoubleLookupTable. -#define DOUBLE_POW5_INV_BITCOUNT 125 -#define DOUBLE_POW5_BITCOUNT 125 - -#define DOUBLE_POW5_INV_TABLE_SIZE 342 -#define DOUBLE_POW5_TABLE_SIZE 326 - -static const uint64_t DOUBLE_POW5_INV_SPLIT[DOUBLE_POW5_INV_TABLE_SIZE][2] = { - { 1u, 2305843009213693952u }, { 11068046444225730970u, 1844674407370955161u }, - { 5165088340638674453u, 1475739525896764129u }, { 7821419487252849886u, 1180591620717411303u }, - { 8824922364862649494u, 1888946593147858085u }, { 7059937891890119595u, 1511157274518286468u }, - { 13026647942995916322u, 1208925819614629174u }, { 9774590264567735146u, 1934281311383406679u }, - { 11509021026396098440u, 1547425049106725343u }, { 16585914450600699399u, 1237940039285380274u }, - { 15469416676735388068u, 1980704062856608439u }, { 16064882156130220778u, 1584563250285286751u }, - { 9162556910162266299u, 1267650600228229401u }, { 7281393426775805432u, 2028240960365167042u }, - { 16893161185646375315u, 1622592768292133633u }, { 2446482504291369283u, 1298074214633706907u }, - { 7603720821608101175u, 2076918743413931051u }, { 2393627842544570617u, 1661534994731144841u }, - { 16672297533003297786u, 1329227995784915872u }, { 11918280793837635165u, 2126764793255865396u }, - { 5845275820328197809u, 1701411834604692317u }, { 15744267100488289217u, 1361129467683753853u }, - { 3054734472329800808u, 2177807148294006166u }, { 17201182836831481939u, 1742245718635204932u }, - { 6382248639981364905u, 1393796574908163946u }, { 2832900194486363201u, 2230074519853062314u }, - { 5955668970331000884u, 1784059615882449851u }, { 1075186361522890384u, 1427247692705959881u }, - { 12788344622662355584u, 2283596308329535809u }, { 13920024512871794791u, 1826877046663628647u }, - { 3757321980813615186u, 1461501637330902918u }, { 10384555214134712795u, 1169201309864722334u }, - { 5547241898389809503u, 1870722095783555735u }, { 4437793518711847602u, 1496577676626844588u }, - { 10928932444453298728u, 1197262141301475670u }, { 17486291911125277965u, 1915619426082361072u }, - { 6610335899416401726u, 1532495540865888858u }, { 12666966349016942027u, 1225996432692711086u }, - { 12888448528943286597u, 1961594292308337738u }, { 17689456452638449924u, 1569275433846670190u }, - { 14151565162110759939u, 1255420347077336152u }, { 7885109000409574610u, 2008672555323737844u }, - { 9997436015069570011u, 1606938044258990275u }, { 7997948812055656009u, 1285550435407192220u }, - { 12796718099289049614u, 2056880696651507552u }, { 2858676849947419045u, 1645504557321206042u }, - { 13354987924183666206u, 1316403645856964833u }, { 17678631863951955605u, 2106245833371143733u }, - { 3074859046935833515u, 1684996666696914987u }, { 13527933681774397782u, 1347997333357531989u }, - { 10576647446613305481u, 2156795733372051183u }, { 15840015586774465031u, 1725436586697640946u }, - { 8982663654677661702u, 1380349269358112757u }, { 18061610662226169046u, 2208558830972980411u }, - { 10759939715039024913u, 1766847064778384329u }, { 12297300586773130254u, 1413477651822707463u }, - { 15986332124095098083u, 2261564242916331941u }, { 9099716884534168143u, 1809251394333065553u }, - { 14658471137111155161u, 1447401115466452442u }, { 4348079280205103483u, 1157920892373161954u }, - { 14335624477811986218u, 1852673427797059126u }, { 7779150767507678651u, 1482138742237647301u }, - { 2533971799264232598u, 1185710993790117841u }, { 15122401323048503126u, 1897137590064188545u }, - { 12097921058438802501u, 1517710072051350836u }, { 5988988032009131678u, 1214168057641080669u }, - { 16961078480698431330u, 1942668892225729070u }, { 13568862784558745064u, 1554135113780583256u }, - { 7165741412905085728u, 1243308091024466605u }, { 11465186260648137165u, 1989292945639146568u }, - { 16550846638002330379u, 1591434356511317254u }, { 16930026125143774626u, 1273147485209053803u }, - { 4951948911778577463u, 2037035976334486086u }, { 272210314680951647u, 1629628781067588869u }, - { 3907117066486671641u, 1303703024854071095u }, { 6251387306378674625u, 2085924839766513752u }, - { 16069156289328670670u, 1668739871813211001u }, { 9165976216721026213u, 1334991897450568801u }, - { 7286864317269821294u, 2135987035920910082u }, { 16897537898041588005u, 1708789628736728065u }, - { 13518030318433270404u, 1367031702989382452u }, { 6871453250525591353u, 2187250724783011924u }, - { 9186511415162383406u, 1749800579826409539u }, { 11038557946871817048u, 1399840463861127631u }, - { 10282995085511086630u, 2239744742177804210u }, { 8226396068408869304u, 1791795793742243368u }, - { 13959814484210916090u, 1433436634993794694u }, { 11267656730511734774u, 2293498615990071511u }, - { 5324776569667477496u, 1834798892792057209u }, { 7949170070475892320u, 1467839114233645767u }, - { 17427382500606444826u, 1174271291386916613u }, { 5747719112518849781u, 1878834066219066582u }, - { 15666221734240810795u, 1503067252975253265u }, { 12532977387392648636u, 1202453802380202612u }, - { 5295368560860596524u, 1923926083808324180u }, { 4236294848688477220u, 1539140867046659344u }, - { 7078384693692692099u, 1231312693637327475u }, { 11325415509908307358u, 1970100309819723960u }, - { 9060332407926645887u, 1576080247855779168u }, { 14626963555825137356u, 1260864198284623334u }, - { 12335095245094488799u, 2017382717255397335u }, { 9868076196075591040u, 1613906173804317868u }, - { 15273158586344293478u, 1291124939043454294u }, { 13369007293925138595u, 2065799902469526871u }, - { 7005857020398200553u, 1652639921975621497u }, { 16672732060544291412u, 1322111937580497197u }, - { 11918976037903224966u, 2115379100128795516u }, { 5845832015580669650u, 1692303280103036413u }, - { 12055363241948356366u, 1353842624082429130u }, { 841837113407818570u, 2166148198531886609u }, - { 4362818505468165179u, 1732918558825509287u }, { 14558301248600263113u, 1386334847060407429u }, - { 12225235553534690011u, 2218135755296651887u }, { 2401490813343931363u, 1774508604237321510u }, - { 1921192650675145090u, 1419606883389857208u }, { 17831303500047873437u, 2271371013423771532u }, - { 6886345170554478103u, 1817096810739017226u }, { 1819727321701672159u, 1453677448591213781u }, - { 16213177116328979020u, 1162941958872971024u }, { 14873036941900635463u, 1860707134196753639u }, - { 15587778368262418694u, 1488565707357402911u }, { 8780873879868024632u, 1190852565885922329u }, - { 2981351763563108441u, 1905364105417475727u }, { 13453127855076217722u, 1524291284333980581u }, - { 7073153469319063855u, 1219433027467184465u }, { 11317045550910502167u, 1951092843947495144u }, - { 12742985255470312057u, 1560874275157996115u }, { 10194388204376249646u, 1248699420126396892u }, - { 1553625868034358140u, 1997919072202235028u }, { 8621598323911307159u, 1598335257761788022u }, - { 17965325103354776697u, 1278668206209430417u }, { 13987124906400001422u, 2045869129935088668u }, - { 121653480894270168u, 1636695303948070935u }, { 97322784715416134u, 1309356243158456748u }, - { 14913111714512307107u, 2094969989053530796u }, { 8241140556867935363u, 1675975991242824637u }, - { 17660958889720079260u, 1340780792994259709u }, { 17189487779326395846u, 2145249268790815535u }, - { 13751590223461116677u, 1716199415032652428u }, { 18379969808252713988u, 1372959532026121942u }, - { 14650556434236701088u, 2196735251241795108u }, { 652398703163629901u, 1757388200993436087u }, - { 11589965406756634890u, 1405910560794748869u }, { 7475898206584884855u, 2249456897271598191u }, - { 2291369750525997561u, 1799565517817278553u }, { 9211793429904618695u, 1439652414253822842u }, - { 18428218302589300235u, 2303443862806116547u }, { 7363877012587619542u, 1842755090244893238u }, - { 13269799239553916280u, 1474204072195914590u }, { 10615839391643133024u, 1179363257756731672u }, - { 2227947767661371545u, 1886981212410770676u }, { 16539753473096738529u, 1509584969928616540u }, - { 13231802778477390823u, 1207667975942893232u }, { 6413489186596184024u, 1932268761508629172u }, - { 16198837793502678189u, 1545815009206903337u }, { 5580372605318321905u, 1236652007365522670u }, - { 8928596168509315048u, 1978643211784836272u }, { 18210923379033183008u, 1582914569427869017u }, - { 7190041073742725760u, 1266331655542295214u }, { 436019273762630246u, 2026130648867672343u }, - { 7727513048493924843u, 1620904519094137874u }, { 9871359253537050198u, 1296723615275310299u }, - { 4726128361433549347u, 2074757784440496479u }, { 7470251503888749801u, 1659806227552397183u }, - { 13354898832594820487u, 1327844982041917746u }, { 13989140502667892133u, 2124551971267068394u }, - { 14880661216876224029u, 1699641577013654715u }, { 11904528973500979224u, 1359713261610923772u }, - { 4289851098633925465u, 2175541218577478036u }, { 18189276137874781665u, 1740432974861982428u }, - { 3483374466074094362u, 1392346379889585943u }, { 1884050330976640656u, 2227754207823337509u }, - { 5196589079523222848u, 1782203366258670007u }, { 15225317707844309248u, 1425762693006936005u }, - { 5913764258841343181u, 2281220308811097609u }, { 8420360221814984868u, 1824976247048878087u }, - { 17804334621677718864u, 1459980997639102469u }, { 17932816512084085415u, 1167984798111281975u }, - { 10245762345624985047u, 1868775676978051161u }, { 4507261061758077715u, 1495020541582440929u }, - { 7295157664148372495u, 1196016433265952743u }, { 7982903447895485668u, 1913626293225524389u }, - { 10075671573058298858u, 1530901034580419511u }, { 4371188443704728763u, 1224720827664335609u }, - { 14372599139411386667u, 1959553324262936974u }, { 15187428126271019657u, 1567642659410349579u }, - { 15839291315758726049u, 1254114127528279663u }, { 3206773216762499739u, 2006582604045247462u }, - { 13633465017635730761u, 1605266083236197969u }, { 14596120828850494932u, 1284212866588958375u }, - { 4907049252451240275u, 2054740586542333401u }, { 236290587219081897u, 1643792469233866721u }, - { 14946427728742906810u, 1315033975387093376u }, { 16535586736504830250u, 2104054360619349402u }, - { 5849771759720043554u, 1683243488495479522u }, { 15747863852001765813u, 1346594790796383617u }, - { 10439186904235184007u, 2154551665274213788u }, { 15730047152871967852u, 1723641332219371030u }, - { 12584037722297574282u, 1378913065775496824u }, { 9066413911450387881u, 2206260905240794919u }, - { 10942479943902220628u, 1765008724192635935u }, { 8753983955121776503u, 1412006979354108748u }, - { 10317025513452932081u, 2259211166966573997u }, { 874922781278525018u, 1807368933573259198u }, - { 8078635854506640661u, 1445895146858607358u }, { 13841606313089133175u, 1156716117486885886u }, - { 14767872471458792434u, 1850745787979017418u }, { 746251532941302978u, 1480596630383213935u }, - { 597001226353042382u, 1184477304306571148u }, { 15712597221132509104u, 1895163686890513836u }, - { 8880728962164096960u, 1516130949512411069u }, { 10793931984473187891u, 1212904759609928855u }, - { 17270291175157100626u, 1940647615375886168u }, { 2748186495899949531u, 1552518092300708935u }, - { 2198549196719959625u, 1242014473840567148u }, { 18275073973719576693u, 1987223158144907436u }, - { 10930710364233751031u, 1589778526515925949u }, { 12433917106128911148u, 1271822821212740759u }, - { 8826220925580526867u, 2034916513940385215u }, { 7060976740464421494u, 1627933211152308172u }, - { 16716827836597268165u, 1302346568921846537u }, { 11989529279587987770u, 2083754510274954460u }, - { 9591623423670390216u, 1667003608219963568u }, { 15051996368420132820u, 1333602886575970854u }, - { 13015147745246481542u, 2133764618521553367u }, { 3033420566713364587u, 1707011694817242694u }, - { 6116085268112601993u, 1365609355853794155u }, { 9785736428980163188u, 2184974969366070648u }, - { 15207286772667951197u, 1747979975492856518u }, { 1097782973908629988u, 1398383980394285215u }, - { 1756452758253807981u, 2237414368630856344u }, { 5094511021344956708u, 1789931494904685075u }, - { 4075608817075965366u, 1431945195923748060u }, { 6520974107321544586u, 2291112313477996896u }, - { 1527430471115325346u, 1832889850782397517u }, { 12289990821117991246u, 1466311880625918013u }, - { 17210690286378213644u, 1173049504500734410u }, { 9090360384495590213u, 1876879207201175057u }, - { 18340334751822203140u, 1501503365760940045u }, { 14672267801457762512u, 1201202692608752036u }, - { 16096930852848599373u, 1921924308174003258u }, { 1809498238053148529u, 1537539446539202607u }, - { 12515645034668249793u, 1230031557231362085u }, { 1578287981759648052u, 1968050491570179337u }, - { 12330676829633449412u, 1574440393256143469u }, { 13553890278448669853u, 1259552314604914775u }, - { 3239480371808320148u, 2015283703367863641u }, { 17348979556414297411u, 1612226962694290912u }, - { 6500486015647617283u, 1289781570155432730u }, { 10400777625036187652u, 2063650512248692368u }, - { 15699319729512770768u, 1650920409798953894u }, { 16248804598352126938u, 1320736327839163115u }, - { 7551343283653851484u, 2113178124542660985u }, { 6041074626923081187u, 1690542499634128788u }, - { 12211557331022285596u, 1352433999707303030u }, { 1091747655926105338u, 2163894399531684849u }, - { 4562746939482794594u, 1731115519625347879u }, { 7339546366328145998u, 1384892415700278303u }, - { 8053925371383123274u, 2215827865120445285u }, { 6443140297106498619u, 1772662292096356228u }, - { 12533209867169019542u, 1418129833677084982u }, { 5295740528502789974u, 2269007733883335972u }, - { 15304638867027962949u, 1815206187106668777u }, { 4865013464138549713u, 1452164949685335022u }, - { 14960057215536570740u, 1161731959748268017u }, { 9178696285890871890u, 1858771135597228828u }, - { 14721654658196518159u, 1487016908477783062u }, { 4398626097073393881u, 1189613526782226450u }, - { 7037801755317430209u, 1903381642851562320u }, { 5630241404253944167u, 1522705314281249856u }, - { 814844308661245011u, 1218164251424999885u }, { 1303750893857992017u, 1949062802279999816u }, - { 15800395974054034906u, 1559250241823999852u }, { 5261619149759407279u, 1247400193459199882u }, - { 12107939454356961969u, 1995840309534719811u }, { 5997002748743659252u, 1596672247627775849u }, - { 8486951013736837725u, 1277337798102220679u }, { 2511075177753209390u, 2043740476963553087u }, - { 13076906586428298482u, 1634992381570842469u }, { 14150874083884549109u, 1307993905256673975u }, - { 4194654460505726958u, 2092790248410678361u }, { 18113118827372222859u, 1674232198728542688u }, - { 3422448617672047318u, 1339385758982834151u }, { 16543964232501006678u, 2143017214372534641u }, - { 9545822571258895019u, 1714413771498027713u }, { 15015355686490936662u, 1371531017198422170u }, - { 5577825024675947042u, 2194449627517475473u }, { 11840957649224578280u, 1755559702013980378u }, - { 16851463748863483271u, 1404447761611184302u }, { 12204946739213931940u, 2247116418577894884u }, - { 13453306206113055875u, 1797693134862315907u }, { 3383947335406624054u, 1438154507889852726u }, - { 16482362180876329456u, 2301047212623764361u }, { 9496540929959153242u, 1840837770099011489u }, - { 11286581558709232917u, 1472670216079209191u }, { 5339916432225476010u, 1178136172863367353u }, - { 4854517476818851293u, 1885017876581387765u }, { 3883613981455081034u, 1508014301265110212u }, - { 14174937629389795797u, 1206411441012088169u }, { 11611853762797942306u, 1930258305619341071u }, - { 5600134195496443521u, 1544206644495472857u }, { 15548153800622885787u, 1235365315596378285u }, - { 6430302007287065643u, 1976584504954205257u }, { 16212288050055383484u, 1581267603963364205u }, - { 12969830440044306787u, 1265014083170691364u }, { 9683682259845159889u, 2024022533073106183u }, - { 15125643437359948558u, 1619218026458484946u }, { 8411165935146048523u, 1295374421166787957u }, - { 17147214310975587960u, 2072599073866860731u }, { 10028422634038560045u, 1658079259093488585u }, - { 8022738107230848036u, 1326463407274790868u }, { 9147032156827446534u, 2122341451639665389u }, - { 11006974540203867551u, 1697873161311732311u }, { 5116230817421183718u, 1358298529049385849u }, - { 15564666937357714594u, 2173277646479017358u }, { 1383687105660440706u, 1738622117183213887u }, - { 12174996128754083534u, 1390897693746571109u }, { 8411947361780802685u, 2225436309994513775u }, - { 6729557889424642148u, 1780349047995611020u }, { 5383646311539713719u, 1424279238396488816u }, - { 1235136468979721303u, 2278846781434382106u }, { 15745504434151418335u, 1823077425147505684u }, - { 16285752362063044992u, 1458461940118004547u }, { 5649904260166615347u, 1166769552094403638u }, - { 5350498001524674232u, 1866831283351045821u }, { 591049586477829062u, 1493465026680836657u }, - { 11540886113407994219u, 1194772021344669325u }, { 18673707743239135u, 1911635234151470921u }, - { 14772334225162232601u, 1529308187321176736u }, { 8128518565387875758u, 1223446549856941389u }, - { 1937583260394870242u, 1957514479771106223u }, { 8928764237799716840u, 1566011583816884978u }, - { 14521709019723594119u, 1252809267053507982u }, { 8477339172590109297u, 2004494827285612772u }, - { 17849917782297818407u, 1603595861828490217u }, { 6901236596354434079u, 1282876689462792174u }, - { 18420676183650915173u, 2052602703140467478u }, { 3668494502695001169u, 1642082162512373983u }, - { 10313493231639821582u, 1313665730009899186u }, { 9122891541139893884u, 2101865168015838698u }, - { 14677010862395735754u, 1681492134412670958u }, { 673562245690857633u, 1345193707530136767u } -}; - -static const uint64_t DOUBLE_POW5_SPLIT[DOUBLE_POW5_TABLE_SIZE][2] = { - { 0u, 1152921504606846976u }, { 0u, 1441151880758558720u }, - { 0u, 1801439850948198400u }, { 0u, 2251799813685248000u }, - { 0u, 1407374883553280000u }, { 0u, 1759218604441600000u }, - { 0u, 2199023255552000000u }, { 0u, 1374389534720000000u }, - { 0u, 1717986918400000000u }, { 0u, 2147483648000000000u }, - { 0u, 1342177280000000000u }, { 0u, 1677721600000000000u }, - { 0u, 2097152000000000000u }, { 0u, 1310720000000000000u }, - { 0u, 1638400000000000000u }, { 0u, 2048000000000000000u }, - { 0u, 1280000000000000000u }, { 0u, 1600000000000000000u }, - { 0u, 2000000000000000000u }, { 0u, 1250000000000000000u }, - { 0u, 1562500000000000000u }, { 0u, 1953125000000000000u }, - { 0u, 1220703125000000000u }, { 0u, 1525878906250000000u }, - { 0u, 1907348632812500000u }, { 0u, 1192092895507812500u }, - { 0u, 1490116119384765625u }, { 4611686018427387904u, 1862645149230957031u }, - { 9799832789158199296u, 1164153218269348144u }, { 12249790986447749120u, 1455191522836685180u }, - { 15312238733059686400u, 1818989403545856475u }, { 14528612397897220096u, 2273736754432320594u }, - { 13692068767113150464u, 1421085471520200371u }, { 12503399940464050176u, 1776356839400250464u }, - { 15629249925580062720u, 2220446049250313080u }, { 9768281203487539200u, 1387778780781445675u }, - { 7598665485932036096u, 1734723475976807094u }, { 274959820560269312u, 2168404344971008868u }, - { 9395221924704944128u, 1355252715606880542u }, { 2520655369026404352u, 1694065894508600678u }, - { 12374191248137781248u, 2117582368135750847u }, { 14651398557727195136u, 1323488980084844279u }, - { 13702562178731606016u, 1654361225106055349u }, { 3293144668132343808u, 2067951531382569187u }, - { 18199116482078572544u, 1292469707114105741u }, { 8913837547316051968u, 1615587133892632177u }, - { 15753982952572452864u, 2019483917365790221u }, { 12152082354571476992u, 1262177448353618888u }, - { 15190102943214346240u, 1577721810442023610u }, { 9764256642163156992u, 1972152263052529513u }, - { 17631875447420442880u, 1232595164407830945u }, { 8204786253993389888u, 1540743955509788682u }, - { 1032610780636961552u, 1925929944387235853u }, { 2951224747111794922u, 1203706215242022408u }, - { 3689030933889743652u, 1504632769052528010u }, { 13834660704216955373u, 1880790961315660012u }, - { 17870034976990372916u, 1175494350822287507u }, { 17725857702810578241u, 1469367938527859384u }, - { 3710578054803671186u, 1836709923159824231u }, { 26536550077201078u, 2295887403949780289u }, - { 11545800389866720434u, 1434929627468612680u }, { 14432250487333400542u, 1793662034335765850u }, - { 8816941072311974870u, 2242077542919707313u }, { 17039803216263454053u, 1401298464324817070u }, - { 12076381983474541759u, 1751623080406021338u }, { 5872105442488401391u, 2189528850507526673u }, - { 15199280947623720629u, 1368455531567204170u }, { 9775729147674874978u, 1710569414459005213u }, - { 16831347453020981627u, 2138211768073756516u }, { 1296220121283337709u, 1336382355046097823u }, - { 15455333206886335848u, 1670477943807622278u }, { 10095794471753144002u, 2088097429759527848u }, - { 6309871544845715001u, 1305060893599704905u }, { 12499025449484531656u, 1631326116999631131u }, - { 11012095793428276666u, 2039157646249538914u }, { 11494245889320060820u, 1274473528905961821u }, - { 532749306367912313u, 1593091911132452277u }, { 5277622651387278295u, 1991364888915565346u }, - { 7910200175544436838u, 1244603055572228341u }, { 14499436237857933952u, 1555753819465285426u }, - { 8900923260467641632u, 1944692274331606783u }, { 12480606065433357876u, 1215432671457254239u }, - { 10989071563364309441u, 1519290839321567799u }, { 9124653435777998898u, 1899113549151959749u }, - { 8008751406574943263u, 1186945968219974843u }, { 5399253239791291175u, 1483682460274968554u }, - { 15972438586593889776u, 1854603075343710692u }, { 759402079766405302u, 1159126922089819183u }, - { 14784310654990170340u, 1448908652612273978u }, { 9257016281882937117u, 1811135815765342473u }, - { 16182956370781059300u, 2263919769706678091u }, { 7808504722524468110u, 1414949856066673807u }, - { 5148944884728197234u, 1768687320083342259u }, { 1824495087482858639u, 2210859150104177824u }, - { 1140309429676786649u, 1381786968815111140u }, { 1425386787095983311u, 1727233711018888925u }, - { 6393419502297367043u, 2159042138773611156u }, { 13219259225790630210u, 1349401336733506972u }, - { 16524074032238287762u, 1686751670916883715u }, { 16043406521870471799u, 2108439588646104644u }, - { 803757039314269066u, 1317774742903815403u }, { 14839754354425000045u, 1647218428629769253u }, - { 4714634887749086344u, 2059023035787211567u }, { 9864175832484260821u, 1286889397367007229u }, - { 16941905809032713930u, 1608611746708759036u }, { 2730638187581340797u, 2010764683385948796u }, - { 10930020904093113806u, 1256727927116217997u }, { 18274212148543780162u, 1570909908895272496u }, - { 4396021111970173586u, 1963637386119090621u }, { 5053356204195052443u, 1227273366324431638u }, - { 15540067292098591362u, 1534091707905539547u }, { 14813398096695851299u, 1917614634881924434u }, - { 13870059828862294966u, 1198509146801202771u }, { 12725888767650480803u, 1498136433501503464u }, - { 15907360959563101004u, 1872670541876879330u }, { 14553786618154326031u, 1170419088673049581u }, - { 4357175217410743827u, 1463023860841311977u }, { 10058155040190817688u, 1828779826051639971u }, - { 7961007781811134206u, 2285974782564549964u }, { 14199001900486734687u, 1428734239102843727u }, - { 13137066357181030455u, 1785917798878554659u }, { 11809646928048900164u, 2232397248598193324u }, - { 16604401366885338411u, 1395248280373870827u }, { 16143815690179285109u, 1744060350467338534u }, - { 10956397575869330579u, 2180075438084173168u }, { 6847748484918331612u, 1362547148802608230u }, - { 17783057643002690323u, 1703183936003260287u }, { 17617136035325974999u, 2128979920004075359u }, - { 17928239049719816230u, 1330612450002547099u }, { 17798612793722382384u, 1663265562503183874u }, - { 13024893955298202172u, 2079081953128979843u }, { 5834715712847682405u, 1299426220705612402u }, - { 16516766677914378815u, 1624282775882015502u }, { 11422586310538197711u, 2030353469852519378u }, - { 11750802462513761473u, 1268970918657824611u }, { 10076817059714813937u, 1586213648322280764u }, - { 12596021324643517422u, 1982767060402850955u }, { 5566670318688504437u, 1239229412751781847u }, - { 2346651879933242642u, 1549036765939727309u }, { 7545000868343941206u, 1936295957424659136u }, - { 4715625542714963254u, 1210184973390411960u }, { 5894531928393704067u, 1512731216738014950u }, - { 16591536947346905892u, 1890914020922518687u }, { 17287239619732898039u, 1181821263076574179u }, - { 16997363506238734644u, 1477276578845717724u }, { 2799960309088866689u, 1846595723557147156u }, - { 10973347230035317489u, 1154122327223216972u }, { 13716684037544146861u, 1442652909029021215u }, - { 12534169028502795672u, 1803316136286276519u }, { 11056025267201106687u, 2254145170357845649u }, - { 18439230838069161439u, 1408840731473653530u }, { 13825666510731675991u, 1761050914342066913u }, - { 3447025083132431277u, 2201313642927583642u }, { 6766076695385157452u, 1375821026829739776u }, - { 8457595869231446815u, 1719776283537174720u }, { 10571994836539308519u, 2149720354421468400u }, - { 6607496772837067824u, 1343575221513417750u }, { 17482743002901110588u, 1679469026891772187u }, - { 17241742735199000331u, 2099336283614715234u }, { 15387775227926763111u, 1312085177259197021u }, - { 5399660979626290177u, 1640106471573996277u }, { 11361262242960250625u, 2050133089467495346u }, - { 11712474920277544544u, 1281333180917184591u }, { 10028907631919542777u, 1601666476146480739u }, - { 7924448521472040567u, 2002083095183100924u }, { 14176152362774801162u, 1251301934489438077u }, - { 3885132398186337741u, 1564127418111797597u }, { 9468101516160310080u, 1955159272639746996u }, - { 15140935484454969608u, 1221974545399841872u }, { 479425281859160394u, 1527468181749802341u }, - { 5210967620751338397u, 1909335227187252926u }, { 17091912818251750210u, 1193334516992033078u }, - { 12141518985959911954u, 1491668146240041348u }, { 15176898732449889943u, 1864585182800051685u }, - { 11791404716994875166u, 1165365739250032303u }, { 10127569877816206054u, 1456707174062540379u }, - { 8047776328842869663u, 1820883967578175474u }, { 836348374198811271u, 2276104959472719343u }, - { 7440246761515338900u, 1422565599670449589u }, { 13911994470321561530u, 1778206999588061986u }, - { 8166621051047176104u, 2222758749485077483u }, { 2798295147690791113u, 1389224218428173427u }, - { 17332926989895652603u, 1736530273035216783u }, { 17054472718942177850u, 2170662841294020979u }, - { 8353202440125167204u, 1356664275808763112u }, { 10441503050156459005u, 1695830344760953890u }, - { 3828506775840797949u, 2119787930951192363u }, { 86973725686804766u, 1324867456844495227u }, - { 13943775212390669669u, 1656084321055619033u }, { 3594660960206173375u, 2070105401319523792u }, - { 2246663100128858359u, 1293815875824702370u }, { 12031700912015848757u, 1617269844780877962u }, - { 5816254103165035138u, 2021587305976097453u }, { 5941001823691840913u, 1263492066235060908u }, - { 7426252279614801142u, 1579365082793826135u }, { 4671129331091113523u, 1974206353492282669u }, - { 5225298841145639904u, 1233878970932676668u }, { 6531623551432049880u, 1542348713665845835u }, - { 3552843420862674446u, 1927935892082307294u }, { 16055585193321335241u, 1204959932551442058u }, - { 10846109454796893243u, 1506199915689302573u }, { 18169322836923504458u, 1882749894611628216u }, - { 11355826773077190286u, 1176718684132267635u }, { 9583097447919099954u, 1470898355165334544u }, - { 11978871809898874942u, 1838622943956668180u }, { 14973589762373593678u, 2298278679945835225u }, - { 2440964573842414192u, 1436424174966147016u }, { 3051205717303017741u, 1795530218707683770u }, - { 13037379183483547984u, 2244412773384604712u }, { 8148361989677217490u, 1402757983365377945u }, - { 14797138505523909766u, 1753447479206722431u }, { 13884737113477499304u, 2191809349008403039u }, - { 15595489723564518921u, 1369880843130251899u }, { 14882676136028260747u, 1712351053912814874u }, - { 9379973133180550126u, 2140438817391018593u }, { 17391698254306313589u, 1337774260869386620u }, - { 3292878744173340370u, 1672217826086733276u }, { 4116098430216675462u, 2090272282608416595u }, - { 266718509671728212u, 1306420176630260372u }, { 333398137089660265u, 1633025220787825465u }, - { 5028433689789463235u, 2041281525984781831u }, { 10060300083759496378u, 1275800953740488644u }, - { 12575375104699370472u, 1594751192175610805u }, { 1884160825592049379u, 1993438990219513507u }, - { 17318501580490888525u, 1245899368887195941u }, { 7813068920331446945u, 1557374211108994927u }, - { 5154650131986920777u, 1946717763886243659u }, { 915813323278131534u, 1216698602428902287u }, - { 14979824709379828129u, 1520873253036127858u }, { 9501408849870009354u, 1901091566295159823u }, - { 12855909558809837702u, 1188182228934474889u }, { 2234828893230133415u, 1485227786168093612u }, - { 2793536116537666769u, 1856534732710117015u }, { 8663489100477123587u, 1160334207943823134u }, - { 1605989338741628675u, 1450417759929778918u }, { 11230858710281811652u, 1813022199912223647u }, - { 9426887369424876662u, 2266277749890279559u }, { 12809333633531629769u, 1416423593681424724u }, - { 16011667041914537212u, 1770529492101780905u }, { 6179525747111007803u, 2213161865127226132u }, - { 13085575628799155685u, 1383226165704516332u }, { 16356969535998944606u, 1729032707130645415u }, - { 15834525901571292854u, 2161290883913306769u }, { 2979049660840976177u, 1350806802445816731u }, - { 17558870131333383934u, 1688508503057270913u }, { 8113529608884566205u, 2110635628821588642u }, - { 9682642023980241782u, 1319147268013492901u }, { 16714988548402690132u, 1648934085016866126u }, - { 11670363648648586857u, 2061167606271082658u }, { 11905663298832754689u, 1288229753919426661u }, - { 1047021068258779650u, 1610287192399283327u }, { 15143834390605638274u, 2012858990499104158u }, - { 4853210475701136017u, 1258036869061940099u }, { 1454827076199032118u, 1572546086327425124u }, - { 1818533845248790147u, 1965682607909281405u }, { 3442426662494187794u, 1228551629943300878u }, - { 13526405364972510550u, 1535689537429126097u }, { 3072948650933474476u, 1919611921786407622u }, - { 15755650962115585259u, 1199757451116504763u }, { 15082877684217093670u, 1499696813895630954u }, - { 9630225068416591280u, 1874621017369538693u }, { 8324733676974063502u, 1171638135855961683u }, - { 5794231077790191473u, 1464547669819952104u }, { 7242788847237739342u, 1830684587274940130u }, - { 18276858095901949986u, 2288355734093675162u }, { 16034722328366106645u, 1430222333808546976u }, - { 1596658836748081690u, 1787777917260683721u }, { 6607509564362490017u, 2234722396575854651u }, - { 1823850468512862308u, 1396701497859909157u }, { 6891499104068465790u, 1745876872324886446u }, - { 17837745916940358045u, 2182346090406108057u }, { 4231062170446641922u, 1363966306503817536u }, - { 5288827713058302403u, 1704957883129771920u }, { 6611034641322878003u, 2131197353912214900u }, - { 13355268687681574560u, 1331998346195134312u }, { 16694085859601968200u, 1664997932743917890u }, - { 11644235287647684442u, 2081247415929897363u }, { 4971804045566108824u, 1300779634956185852u }, - { 6214755056957636030u, 1625974543695232315u }, { 3156757802769657134u, 2032468179619040394u }, - { 6584659645158423613u, 1270292612261900246u }, { 17454196593302805324u, 1587865765327375307u }, - { 17206059723201118751u, 1984832206659219134u }, { 6142101308573311315u, 1240520129162011959u }, - { 3065940617289251240u, 1550650161452514949u }, { 8444111790038951954u, 1938312701815643686u }, - { 665883850346957067u, 1211445438634777304u }, { 832354812933696334u, 1514306798293471630u }, - { 10263815553021896226u, 1892883497866839537u }, { 17944099766707154901u, 1183052186166774710u }, - { 13206752671529167818u, 1478815232708468388u }, { 16508440839411459773u, 1848519040885585485u }, - { 12623618533845856310u, 1155324400553490928u }, { 15779523167307320387u, 1444155500691863660u }, - { 1277659885424598868u, 1805194375864829576u }, { 1597074856780748586u, 2256492969831036970u }, - { 5609857803915355770u, 1410308106144398106u }, { 16235694291748970521u, 1762885132680497632u }, - { 1847873790976661535u, 2203606415850622041u }, { 12684136165428883219u, 1377254009906638775u }, - { 11243484188358716120u, 1721567512383298469u }, { 219297180166231438u, 2151959390479123087u }, - { 7054589765244976505u, 1344974619049451929u }, { 13429923224983608535u, 1681218273811814911u }, - { 12175718012802122765u, 2101522842264768639u }, { 14527352785642408584u, 1313451776415480399u }, - { 13547504963625622826u, 1641814720519350499u }, { 12322695186104640628u, 2052268400649188124u }, - { 16925056528170176201u, 1282667750405742577u }, { 7321262604930556539u, 1603334688007178222u }, - { 18374950293017971482u, 2004168360008972777u }, { 4566814905495150320u, 1252605225005607986u }, - { 14931890668723713708u, 1565756531257009982u }, { 9441491299049866327u, 1957195664071262478u }, - { 1289246043478778550u, 1223247290044539049u }, { 6223243572775861092u, 1529059112555673811u }, - { 3167368447542438461u, 1911323890694592264u }, { 1979605279714024038u, 1194577431684120165u }, - { 7086192618069917952u, 1493221789605150206u }, { 18081112809442173248u, 1866527237006437757u }, - { 13606538515115052232u, 1166579523129023598u }, { 7784801107039039482u, 1458224403911279498u }, - { 507629346944023544u, 1822780504889099373u }, { 5246222702107417334u, 2278475631111374216u }, - { 3278889188817135834u, 1424047269444608885u }, { 8710297504448807696u, 1780059086805761106u } -}; - -// IEEE 754 double precision constants -#define DOUBLE_MANTISSA_BITS 52 -#define DOUBLE_EXPONENT_BITS 11 -#define DOUBLE_EXPONENT_BIAS 1023 - -// Helper: floor(log2(value)) using ryu_leading_zeros64 -static inline uint32_t floor_log2(const uint64_t value) { - return 63 - ryu_leading_zeros64(value); -} - -// Helper: log2(5^e) approximation -static inline int32_t log2pow5(const int32_t e) { - return (int32_t) ((((uint32_t) e) * 1217359) >> 19); -} - -// Helper: ceil(log2(5^e)) -static inline int32_t ceil_log2pow5(const int32_t e) { - return log2pow5(e) + 1; -} - -// Helper: max of two int32 -static inline int32_t max32(int32_t a, int32_t b) { - return a < b ? b : a; -} - -// Helper: convert uint64 bits to double -static inline double int64Bits2Double(uint64_t bits) { - double f; - memcpy(&f, &bits, sizeof(double)); - return f; -} - -// Check if value is multiple of 2^p -static inline bool multipleOfPowerOf2(const uint64_t value, const uint32_t p) { - return (value & ((1ull << p) - 1)) == 0; -} - -// Count how many times value is divisible by 5 -// Uses modular inverse to avoid expensive division -static inline uint32_t pow5Factor(uint64_t value) { - const uint64_t m_inv_5 = 14757395258967641293u; // 5 * m_inv_5 = 1 (mod 2^64) - const uint64_t n_div_5 = 3689348814741910323u; // 2^64 / 5 - uint32_t count = 0; - for (;;) { - value *= m_inv_5; - if (value > n_div_5) - break; - ++count; - } - return count; -} - -// Check if value is multiple of 5^p -// Optimized: uses modular inverse instead of division -static inline bool multipleOfPowerOf5(const uint64_t value, const uint32_t p) { - return pow5Factor(value) >= p; -} - -// 128-bit multiplication with shift -// This is the core operation for converting decimal to binary -#if defined(__SIZEOF_INT128__) -// Use native 128-bit integers if available (GCC/Clang) -static inline uint64_t mulShift64(const uint64_t m, const uint64_t* const mul, const int32_t j) { - const unsigned __int128 b0 = ((unsigned __int128) m) * mul[0]; - const unsigned __int128 b2 = ((unsigned __int128) m) * mul[1]; - return (uint64_t) (((b0 >> 64) + b2) >> (j - 64)); -} -#else -// Fallback for systems without 128-bit integers -static inline uint64_t umul128(const uint64_t a, const uint64_t b, uint64_t* const productHi) { - const uint32_t aLo = (uint32_t)a; - const uint32_t aHi = (uint32_t)(a >> 32); - const uint32_t bLo = (uint32_t)b; - const uint32_t bHi = (uint32_t)(b >> 32); - - const uint64_t b00 = (uint64_t)aLo * bLo; - const uint64_t b01 = (uint64_t)aLo * bHi; - const uint64_t b10 = (uint64_t)aHi * bLo; - const uint64_t b11 = (uint64_t)aHi * bHi; - - const uint32_t b00Lo = (uint32_t)b00; - const uint32_t b00Hi = (uint32_t)(b00 >> 32); - - const uint64_t mid1 = b10 + b00Hi; - const uint32_t mid1Lo = (uint32_t)(mid1); - const uint32_t mid1Hi = (uint32_t)(mid1 >> 32); - - const uint64_t mid2 = b01 + mid1Lo; - const uint32_t mid2Lo = (uint32_t)(mid2); - const uint32_t mid2Hi = (uint32_t)(mid2 >> 32); - - const uint64_t pHi = b11 + mid1Hi + mid2Hi; - const uint64_t pLo = ((uint64_t)mid2Lo << 32) | b00Lo; - - *productHi = pHi; - return pLo; -} - -static inline uint64_t shiftright128(const uint64_t lo, const uint64_t hi, const uint32_t dist) { - return (hi << (64 - dist)) | (lo >> dist); -} - -static inline uint64_t mulShift64(const uint64_t m, const uint64_t* const mul, const int32_t j) { - uint64_t high1; - const uint64_t low1 = umul128(m, mul[1], &high1); - uint64_t high0; - umul128(m, mul[0], &high0); - const uint64_t sum = high0 + low1; - if (sum < high0) { - ++high1; - } - return shiftright128(sum, high1, j - 64); -} -#endif - -// Main conversion function: decimal mantissa+exponent to IEEE 754 double -// Optimized for JSON parsing with fast paths for edge cases -static inline double ryu_s2d_from_parts(uint64_t m10, int m10digits, int32_t e10, bool signedM) { - // Fast path: handle zero explicitly (e.g., "0.0", "0e0") - if (m10 == 0) { - return int64Bits2Double(((uint64_t) signedM) << 63); - } - - // Fast path: handle overflow/underflow early - if (m10digits + e10 <= -324) { - // Underflow to zero - return int64Bits2Double(((uint64_t) signedM) << 63); - } - - if (m10digits + e10 >= 310) { - // Overflow to infinity - return int64Bits2Double((((uint64_t) signedM) << 63) | 0x7ff0000000000000ULL); - } - - // Convert decimal to binary: m10 * 10^e10 = m2 * 2^e2 - int32_t e2; - uint64_t m2; - bool trailingZeros; - - if (e10 >= 0) { - // Positive exponent: multiply by 5^e10 and adjust binary exponent - e2 = floor_log2(m10) + e10 + log2pow5(e10) - (DOUBLE_MANTISSA_BITS + 1); - int j = e2 - e10 - ceil_log2pow5(e10) + DOUBLE_POW5_BITCOUNT; - m2 = mulShift64(m10, DOUBLE_POW5_SPLIT[e10], j); - trailingZeros = e2 < e10 || (e2 - e10 < 64 && multipleOfPowerOf2(m10, e2 - e10)); - } else { - // Negative exponent: divide by 5^(-e10) - e2 = floor_log2(m10) + e10 - ceil_log2pow5(-e10) - (DOUBLE_MANTISSA_BITS + 1); - int j = e2 - e10 + ceil_log2pow5(-e10) - 1 + DOUBLE_POW5_INV_BITCOUNT; - m2 = mulShift64(m10, DOUBLE_POW5_INV_SPLIT[-e10], j); - trailingZeros = multipleOfPowerOf5(m10, -e10); - } - - // Compute IEEE 754 exponent - uint32_t ieee_e2 = (uint32_t) max32(0, e2 + DOUBLE_EXPONENT_BIAS + floor_log2(m2)); - - if (ieee_e2 > 0x7fe) { - // Overflow to infinity - return int64Bits2Double((((uint64_t) signedM) << 63) | 0x7ff0000000000000ULL); - } - - // Compute shift amount for rounding - int32_t shift = (ieee_e2 == 0 ? 1 : ieee_e2) - e2 - DOUBLE_EXPONENT_BIAS - DOUBLE_MANTISSA_BITS; - - // IEEE 754 round-to-even (banker's rounding) - trailingZeros &= (m2 & ((1ull << (shift - 1)) - 1)) == 0; - uint64_t lastRemovedBit = (m2 >> (shift - 1)) & 1; - bool roundUp = (lastRemovedBit != 0) && (!trailingZeros || (((m2 >> shift) & 1) != 0)); - - uint64_t ieee_m2 = (m2 >> shift) + roundUp; - ieee_m2 &= (1ull << DOUBLE_MANTISSA_BITS) - 1; - - if (ieee_m2 == 0 && roundUp) { - ieee_e2++; - } - - // Pack sign, exponent, and mantissa into IEEE 754 format - // Match original Ryu: group sign+exponent, then shift and add mantissa - uint64_t ieee = (((((uint64_t) signedM) << DOUBLE_EXPONENT_BITS) | (uint64_t)ieee_e2) << DOUBLE_MANTISSA_BITS) | ieee_m2; - return int64Bits2Double(ieee); -} - -#endif // RYU_H diff --git a/test/json/json_ryu_fallback_test.rb b/test/json/json_float_parser_fallback_test.rb similarity index 85% rename from test/json/json_ryu_fallback_test.rb rename to test/json/json_float_parser_fallback_test.rb index a61b3e66..39801d90 100644 --- a/test/json/json_ryu_fallback_test.rb +++ b/test/json/json_float_parser_fallback_test.rb @@ -5,31 +5,25 @@ rescue LoadError end -class JSONRyuFallbackTest < Test::Unit::TestCase +class JSONFloatParserFallbackTest < Test::Unit::TestCase include JSON - # Test that numbers with more than 17 significant digits fall back to rb_cstr_to_dbl - def test_more_than_17_significant_digits - # These numbers have > 17 significant digits and should use fallback path - # They should still parse correctly, just not via the Ryu optimization + # Test that numbers with more than 18 significant digits fall back to rb_cstr_to_dbl + def test_more_than_18_significant_digits + # These numbers have > 18 significant digits and should use fallback path. + # They should still parse correctly, just not via the Fast Float optimization - test_cases = [ - # input, expected (rounded to double precision) - ["1.23456789012345678901234567890", 1.2345678901234567], - ["123456789012345678.901234567890", 1.2345678901234568e+17], - ["0.123456789012345678901234567890", 0.12345678901234568], - ["9999999999999999999999999999.9", 1.0e+28], - # Edge case: exactly 18 digits - ["123456789012345678", 123456789012345680.0], - # Many fractional digits - ["0.12345678901234567890123456789", 0.12345678901234568], - ] + # input, expected (rounded to double precision) + assert_float_parsing "1.23456789012345678901234567890" + assert_float_parsing "123456789012345678.901234567890" + assert_float_parsing "0.123456789012345678901234567890" + assert_float_parsing "9999999999999999999999999999.9" - test_cases.each do |input, expected| - result = JSON.parse(input) - assert_in_delta(expected, result, 1e-10, - "Failed to parse #{input} correctly (>17 digits, fallback path)") - end + # Edge case: exactly 18 digits + assert_float_parsing "123456789012345678.0" + + # Many fractional digits + assert_float_parsing "0.12345678901234567890123456789" end # Test decimal_class option forces fallback @@ -188,4 +182,10 @@ def test_large_exponent_numbers assert_equal 0.0, JSON.parse("1e-18446744073709551615") assert_equal 0.0, JSON.parse("1e-9223372036854775809") end + + private + + def assert_float_parsing(number) + assert_equal(Float(number), JSON.parse(number), "Failed to parse #{number} correctly") + end end diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index a4292871..c1aa2f61 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -60,7 +60,8 @@ def test_parse_values assert_equal(-23, parse('-23')) assert_equal(23, parse('23')) assert_in_delta(0.23, parse('0.23'), 1e-2) - assert_in_delta(0.0, parse('0e0'), 1e-2) + assert_equal(0.0, parse('0e0')) + assert_equal(-0.0, parse('-0e0')) assert_equal("", parse('""')) assert_equal("foobar", parse('"foobar"')) end