From 1cbe0458bd11ef15dc93b7de5380b7ce381b7350 Mon Sep 17 00:00:00 2001 From: zeriyoshi Date: Mon, 11 Jan 2021 05:11:00 +0900 Subject: [PATCH 1/2] implementation of RFC --- ...flectionExtension_getClassNames_basic.phpt | 22 +- ext/standard/array.c | 26 +- ext/standard/basic_functions.c | 3 + ext/standard/basic_functions.stub.php | 12 +- ext/standard/config.m4 | 7 +- ext/standard/config.w32 | 2 +- ext/standard/php_rng.h | 49 + ext/standard/rng.c | 273 +++++ ext/standard/rng_mt19937.c | 272 +++++ ext/standard/rng_mt19937.h | 96 ++ ext/standard/rng_mt19937.stub.php | 15 + ext/standard/rng_mt19937_arginfo.h | 35 + ext/standard/rng_osrng.c | 96 ++ ext/standard/rng_osrng.h | 26 + ext/standard/rng_osrng.stub.php | 12 + ext/standard/rng_osrng_arginfo.h | 18 + ext/standard/rng_rng64interface.stub.php | 11 + ext/standard/rng_rng64interface_arginfo.h | 13 + ext/standard/rng_rnginterface.stub.php | 10 + ext/standard/rng_rnginterface_arginfo.h | 13 + ext/standard/rng_xorshift128plus.c | 206 ++++ ext/standard/rng_xorshift128plus.h | 32 + ext/standard/rng_xorshift128plus.stub.php | 15 + ext/standard/rng_xorshift128plus_arginfo.h | 35 + ext/standard/string.c | 12 +- .../tests/rng/_clonable_rng_classes.inc | 5 + ext/standard/tests/rng/_rng_classes.inc | 6 + .../tests/rng/_serializable_rng_classes.inc | 5 + ext/standard/tests/rng/class_clone.phpt | 22 + ext/standard/tests/rng/class_inheritance.phpt | 20 + ext/standard/tests/rng/class_serialize.phpt | 35 + .../tests/rng/class_serialize_64.phpt | 41 + ext/standard/tests/rng/class_userland.phpt | 61 + .../tests/rng/class_userland_extend.phpt | 33 + .../tests/rng/function_array_rand.phpt | 35 + .../tests/rng/function_rng_bytes.phpt | 21 + .../tests/rng/function_rng_bytes_string.phpt | 68 ++ ext/standard/tests/rng/function_rng_rand.phpt | 21 + .../tests/rng/function_rng_rand_64.phpt | 27 + ext/standard/tests/rng/function_shuffle.phpt | 24 + .../tests/rng/function_str_shuffle.phpt | 22 + ext/standard/tests/rng/method_next.phpt | 15 + ext/standard/tests/rng/method_next_64.phpt | 21 + .../tests/rng/mt19937_consistency.phpt | 62 + ext/standard/tests/rng/mt19937_result.phpt | 1021 ++++++++++++++++ ext/standard/tests/rng/mt19937_result_64.phpt | 1027 +++++++++++++++++ .../rng/mt19937_unserialize_unexcepted.phpt | 15 + .../tests/rng/xorshift128plus_result.phpt | 1021 ++++++++++++++++ .../tests/rng/xorshift128plus_result_64.phpt | 1027 +++++++++++++++++ ...orshift128plus_unserialize_unexcepted.phpt | 15 + 50 files changed, 5955 insertions(+), 26 deletions(-) create mode 100644 ext/standard/php_rng.h create mode 100644 ext/standard/rng.c create mode 100644 ext/standard/rng_mt19937.c create mode 100644 ext/standard/rng_mt19937.h create mode 100644 ext/standard/rng_mt19937.stub.php create mode 100644 ext/standard/rng_mt19937_arginfo.h create mode 100644 ext/standard/rng_osrng.c create mode 100644 ext/standard/rng_osrng.h create mode 100644 ext/standard/rng_osrng.stub.php create mode 100644 ext/standard/rng_osrng_arginfo.h create mode 100644 ext/standard/rng_rng64interface.stub.php create mode 100644 ext/standard/rng_rng64interface_arginfo.h create mode 100644 ext/standard/rng_rnginterface.stub.php create mode 100644 ext/standard/rng_rnginterface_arginfo.h create mode 100644 ext/standard/rng_xorshift128plus.c create mode 100644 ext/standard/rng_xorshift128plus.h create mode 100644 ext/standard/rng_xorshift128plus.stub.php create mode 100644 ext/standard/rng_xorshift128plus_arginfo.h create mode 100644 ext/standard/tests/rng/_clonable_rng_classes.inc create mode 100644 ext/standard/tests/rng/_rng_classes.inc create mode 100644 ext/standard/tests/rng/_serializable_rng_classes.inc create mode 100644 ext/standard/tests/rng/class_clone.phpt create mode 100644 ext/standard/tests/rng/class_inheritance.phpt create mode 100644 ext/standard/tests/rng/class_serialize.phpt create mode 100644 ext/standard/tests/rng/class_serialize_64.phpt create mode 100644 ext/standard/tests/rng/class_userland.phpt create mode 100644 ext/standard/tests/rng/class_userland_extend.phpt create mode 100644 ext/standard/tests/rng/function_array_rand.phpt create mode 100644 ext/standard/tests/rng/function_rng_bytes.phpt create mode 100644 ext/standard/tests/rng/function_rng_bytes_string.phpt create mode 100644 ext/standard/tests/rng/function_rng_rand.phpt create mode 100644 ext/standard/tests/rng/function_rng_rand_64.phpt create mode 100644 ext/standard/tests/rng/function_shuffle.phpt create mode 100644 ext/standard/tests/rng/function_str_shuffle.phpt create mode 100644 ext/standard/tests/rng/method_next.phpt create mode 100644 ext/standard/tests/rng/method_next_64.phpt create mode 100644 ext/standard/tests/rng/mt19937_consistency.phpt create mode 100644 ext/standard/tests/rng/mt19937_result.phpt create mode 100644 ext/standard/tests/rng/mt19937_result_64.phpt create mode 100644 ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt create mode 100644 ext/standard/tests/rng/xorshift128plus_result.phpt create mode 100644 ext/standard/tests/rng/xorshift128plus_result_64.phpt create mode 100644 ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt diff --git a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt index 5c4d1cb87f1d7..a8d4cd64a2922 100644 --- a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt +++ b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt @@ -7,14 +7,24 @@ Felix De Vliegher $standard = new ReflectionExtension('standard'); var_dump($standard->getClassNames()); ?> ---EXPECT-- -array(4) { +--EXPECTF-- +array(9) { [0]=> - string(22) "__PHP_Incomplete_Class" + %s(22) "__PHP_Incomplete_Class" [1]=> - string(14) "AssertionError" + %s(15) "php_user_filter" [2]=> - string(15) "php_user_filter" + %s(9) "Directory" [3]=> - string(9) "Directory" + %s(14) "AssertionError" + [4]=> + %s(16) "RNG\RNGInterface" + [5]=> + %s(18) "RNG\RNG64Interface" + [6]=> + %s(19) "RNG\XorShift128Plus" + [7]=> + %s(11) "RNG\MT19937" + [8]=> + %s(9) "RNG\OSRNG" } diff --git a/ext/standard/array.c b/ext/standard/array.c index e0b52ca169256..bd96409ca7942 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -42,6 +42,7 @@ #include "zend_bitset.h" #include "zend_exceptions.h" #include "ext/spl/spl_array.h" +#include "php_rng.h" /* {{{ defines */ #define EXTR_OVERWRITE 0 @@ -2828,7 +2829,7 @@ PHP_FUNCTION(range) #undef RANGE_CHECK_DOUBLE_INIT_ARRAY #undef RANGE_CHECK_LONG_INIT_ARRAY -static void php_array_data_shuffle(zval *array) /* {{{ */ +static void php_array_data_shuffle(zval *array, zval *zrng) /* {{{ */ { uint32_t idx, j, n_elems; Bucket *p, temp; @@ -2857,7 +2858,7 @@ static void php_array_data_shuffle(zval *array) /* {{{ */ } } while (--n_left) { - rnd_idx = php_mt_rand_range(0, n_left); + rnd_idx = zrng ? php_rng_range(zrng, 0, n_left) : php_mt_rand_range(0, n_left); if (rnd_idx != n_left) { temp = hash->arData[n_left]; hash->arData[n_left] = hash->arData[rnd_idx]; @@ -2882,7 +2883,7 @@ static void php_array_data_shuffle(zval *array) /* {{{ */ } } while (--n_left) { - rnd_idx = php_mt_rand_range(0, n_left); + rnd_idx = zrng ? php_rng_range(zrng, 0, n_left) : php_mt_rand_range(0, n_left); if (rnd_idx != n_left) { temp = hash->arData[n_left]; hash->arData[n_left] = hash->arData[rnd_idx]; @@ -2912,13 +2913,15 @@ static void php_array_data_shuffle(zval *array) /* {{{ */ /* {{{ Randomly shuffle the contents of an array */ PHP_FUNCTION(shuffle) { - zval *array; + zval *array, *zrng = NULL; - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_ARRAY_EX(array, 0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(zrng, rng_ce_RNG_RNGInterface) ZEND_PARSE_PARAMETERS_END(); - php_array_data_shuffle(array); + php_array_data_shuffle(array, zrng); RETURN_TRUE; } @@ -5556,7 +5559,7 @@ PHP_FUNCTION(array_multisort) /* {{{ Return key/keys for random entry/entries in the array */ PHP_FUNCTION(array_rand) { - zval *input; + zval *input, *zrng = NULL; zend_long num_req = 1; zend_string *string_key; zend_ulong num_key; @@ -5567,10 +5570,11 @@ PHP_FUNCTION(array_rand) uint32_t bitset_len; ALLOCA_FLAG(use_heap) - ZEND_PARSE_PARAMETERS_START(1, 2) + ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_ARRAY(input) Z_PARAM_OPTIONAL Z_PARAM_LONG(num_req) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(zrng, rng_ce_RNG_RNGInterface) ZEND_PARSE_PARAMETERS_END(); num_avail = zend_hash_num_elements(Z_ARRVAL_P(input)); @@ -5586,7 +5590,7 @@ PHP_FUNCTION(array_rand) if ((uint32_t)num_avail < ht->nNumUsed - (ht->nNumUsed>>1)) { /* If less than 1/2 of elements are used, don't sample. Instead search for a * specific offset using linear scan. */ - zend_long i = 0, randval = php_mt_rand_range(0, num_avail - 1); + zend_long i = 0, randval = zrng ? php_rng_range(zrng, 0, num_avail - 1) : php_mt_rand_range(0, num_avail - 1); ZEND_HASH_FOREACH_KEY(Z_ARRVAL_P(input), num_key, string_key) { if (i == randval) { if (string_key) { @@ -5604,7 +5608,7 @@ PHP_FUNCTION(array_rand) * probability of hitting N empty elements in a row is (1-1/2)**N. * For N=10 this becomes smaller than 0.1%. */ do { - zend_long randval = php_mt_rand_range(0, ht->nNumUsed - 1); + zend_long randval = zrng ? php_rng_range(zrng, 0, ht->nNumUsed - 1) : php_mt_rand_range(0, ht->nNumUsed - 1); Bucket *bucket = &ht->arData[randval]; if (!Z_ISUNDEF(bucket->val)) { if (bucket->key) { @@ -5634,7 +5638,7 @@ PHP_FUNCTION(array_rand) i = num_req; while (i) { - zend_long randval = php_mt_rand_range(0, num_avail - 1); + zend_long randval = zrng ? php_rng_range(zrng, 0, num_avail - 1) : php_mt_rand_range(0, num_avail - 1); if (!zend_bitset_in(bitset, randval)) { zend_bitset_incl(bitset, randval); i--; diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 1f598aa540b1f..f530c6d52d3d3 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -34,6 +34,7 @@ #include "ext/standard/php_uuencode.h" #include "ext/standard/php_mt_rand.h" #include "ext/standard/crc32_x86.h" +#include "ext/standard/php_rng.h" #ifdef PHP_WIN32 #include "win32/php_win32_globals.h" @@ -412,6 +413,8 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ BASIC_MINIT_SUBMODULE(hrtime) + BASIC_MINIT_SUBMODULE(rng) + return SUCCESS; } /* }}} */ diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 76525762a2af9..bbb8545015bb4 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -139,7 +139,7 @@ function array_fill_keys(array $keys, mixed $value): array {} */ function range($start, $end, int|float $step = 1): array {} -function shuffle(array &$array): bool {} +function shuffle(array &$array, ?RNG\RNGInterface $rng = null): bool {} function array_pop(array &$array): mixed {} @@ -231,7 +231,7 @@ function array_udiff_uassoc(array $array, ...$rest): array {} */ function array_multisort(&$array, &...$rest): bool {} -function array_rand(array $array, int $num = 1): int|string|array {} +function array_rand(array $array, int $num = 1, ?RNG\RNGInterface $rng = null): int|string|array {} function array_sum(array $array): int|float {} @@ -683,7 +683,7 @@ function sscanf(string $string, string $format, mixed &...$vars): array|int|null function str_rot13(string $string): string {} -function str_shuffle(string $string): string {} +function str_shuffle(string $string, ?RNG\RNGInterface $rng = null): string {} function str_word_count(string $string, int $format = 0, ?string $characters = null): array|int {} @@ -1203,6 +1203,12 @@ function random_bytes(int $length): string {} function random_int(int $min, int $max): int {} +/* rng.c */ + +function rng_rand(RNG\RNGInterface $rng, int $min = UNKNOWN, int $max = UNKNOWN): int {} + +function rng_bytes(RNG\RNGInterface $rng, int $length): string {} + /* soundex.c */ function soundex(string $string): string {} diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index d04add96298e9..bc6c968b29239 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -426,6 +426,11 @@ else AC_MSG_RESULT(no) fi +dnl +dnl rng +dnl +PHP_ADD_SOURCES(PHP_EXT_DIR(standard), rng_xorshift128plus.c rng_mt19937.c rng_osrng.c) + dnl dnl Setup extension sources dnl @@ -440,7 +445,7 @@ PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32. http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ filters.c proc_open.c streamsfuncs.c http.c password.c \ - random.c net.c hrtime.c crc32_x86.c,,, + random.c net.c hrtime.c crc32_x86.c rng.c,,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_MAKEFILE_FRAGMENT diff --git a/ext/standard/config.w32 b/ext/standard/config.w32 index 3de43d04c067e..289e8b903d617 100644 --- a/ext/standard/config.w32 +++ b/ext/standard/config.w32 @@ -35,7 +35,7 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \ url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \ php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \ user_filters.c uuencode.c filters.c proc_open.c password.c \ - streamsfuncs.c http.c flock_compat.c random.c hrtime.c", false /* never shared */, + streamsfuncs.c http.c flock_compat.c random.c hrtime.c rng.c rng_mt19937.c rng_osrng.c rng_xorshift128plus.c", false /* never shared */, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); PHP_STANDARD = "yes"; ADD_MAKEFILE_FRAGMENT(); diff --git a/ext/standard/php_rng.h b/ext/standard/php_rng.h new file mode 100644 index 0000000000000..d66dbedb2d0d1 --- /dev/null +++ b/ext/standard/php_rng.h @@ -0,0 +1,49 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Go Kudo | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_RNG_H +#define PHP_RNG_H + +#include "php.h" + +extern PHPAPI zend_class_entry *rng_ce_RNG_RNGInterface; +extern PHPAPI zend_class_entry *rng_ce_RNG_RNG64Interface; + +typedef struct _php_rng php_rng; +typedef struct _php_rng { + uint32_t (*next)(php_rng*); + uint64_t (*next64)(php_rng*); + zend_long (*range)(php_rng*); // optional for object defined range implementation. + void *state; + zend_object std; +} php_rng; + +static inline php_rng *rng_from_obj(zend_object *obj) { + return (php_rng*)((char*)(obj) - XtOffsetOf(php_rng, std)); +} + +#define Z_RNG_P(zval) rng_from_obj(Z_OBJ_P(zval)) + +PHP_MINIT_FUNCTION(rng); + +#define RNG_NAMESPACE "RNG\\" + +PHPAPI php_rng *php_rng_initialize(uint32_t (*next)(php_rng*), uint64_t (*next64)(php_rng*)); +PHPAPI int php_rng_next(uint32_t*, zval*); +PHPAPI int php_rng_next64(uint64_t*, zval*); +PHPAPI zend_long php_rng_range(zval*, zend_long, zend_long); + +#endif diff --git a/ext/standard/rng.c b/ext/standard/rng.c new file mode 100644 index 0000000000000..185b38d64242f --- /dev/null +++ b/ext/standard/rng.c @@ -0,0 +1,273 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Go Kudo | + +----------------------------------------------------------------------+ +*/ + +#include + +#include "php.h" +#include "php_rng.h" + +#include "rng_rnginterface_arginfo.h" +#include "rng_rng64interface_arginfo.h" + +#include "rng_xorshift128plus.h" +#include "rng_mt19937.h" +#include "rng_osrng.h" + +PHPAPI zend_class_entry *rng_ce_RNG_RNGInterface; +PHPAPI zend_class_entry *rng_ce_RNG_RNG64Interface; + +PHPAPI php_rng* php_rng_initialize(uint32_t (*next)(php_rng*), uint64_t (*next64)(php_rng*)) +{ + php_rng *rng = (php_rng*)ecalloc(1, sizeof(php_rng)); + rng->next = next; + rng->next64 = next64; + + return rng; +} + +PHPAPI int php_rng_next(uint32_t *result, zval *obj) +{ + /* If internal classes, use php_rng struct. */ + if (Z_OBJCE_P(obj)->type == ZEND_INTERNAL_CLASS) { + php_rng *rng = Z_RNG_P(obj); + + if (rng->next) { + *result = rng->next(rng); + } else if (rng->next64) { + *result = (uint32_t) (rng->next64(rng)); + } else { + return FAILURE; + } + + return SUCCESS; + } + + zend_function *function; + zval function_name, retval; + + ZVAL_STRING(&function_name, "next"); + function = zend_hash_find_ptr(&Z_OBJCE_P(obj)->function_table, Z_STR(function_name)); + zval_ptr_dtor(&function_name); + + if (!function) { + return FAILURE; + } + + zend_call_known_instance_method_with_0_params(function, Z_OBJ_P(obj), &retval); + *result = Z_LVAL(retval); + + return SUCCESS; +} + +PHPAPI int php_rng_next64(uint64_t *result, zval *obj) +{ + /* If internal classes, use php_rng struct. */ + if (Z_OBJCE_P(obj)->type == ZEND_INTERNAL_CLASS) { + php_rng *rng = Z_RNG_P(obj); + + if (rng->next64) { + *result = rng->next64(rng); + } else if (rng->next) { + *result = rng->next(rng); + *result = (*result << 32) | rng->next(rng); + } else { + return FAILURE; + } + + return SUCCESS; + } + + zend_function *function; + zval function_name, retval; + + ZVAL_STRING(&function_name, "next64"); + function = zend_hash_find_ptr(&Z_OBJCE_P(obj)->function_table, Z_STR(function_name)); + zval_ptr_dtor(&function_name); + + if (!function) { + return FAILURE; + } + + zend_call_known_instance_method_with_0_params(function, Z_OBJ_P(obj), &retval); + *result = Z_LVAL(retval); + + return SUCCESS; +} + +static uint32_t rng_rand_range32(zval *obj, uint32_t umax) +{ + uint32_t result, limit; + + php_rng_next(&result, obj); + + /* Special case where no modulus is required */ + if (UNEXPECTED(umax == UINT32_MAX)) { + return result; + } + + /* Increment the max so the range is inclusive of max */ + umax++; + + /* Powers of two are not biased */ + if ((umax & (umax - 1)) == 0) { + return result & (umax - 1); + } + + /* Ceiling under which UINT32_MAX % max == 0 */ + limit = UINT32_MAX - (UINT32_MAX % umax) - 1; + + /* Discard numbers over the limit to avoid modulo bias */ + while (UNEXPECTED(result > limit)) { + php_rng_next(&result, obj); + } + + return result % umax; +} + +#if ZEND_ULONG_MAX > UINT32_MAX +static uint64_t rng_rand_range64(zval *obj, uint64_t umax) +{ + uint64_t result, limit; + + php_rng_next64(&result, obj); + + /* Special case where no modulus is required */ + if (UNEXPECTED(umax == UINT64_MAX)) { + return result; + } + + /* Increment the max so the range is inclusive of max */ + umax++; + + /* Powers of two are not biased */ + if ((umax & (umax - 1)) == 0) { + return result & (umax - 1); + } + + /* Ceiling under which UINT64_MAX % max == 0 */ + limit = UINT64_MAX - (UINT64_MAX % umax) - 1; + + /* Discard numbers over the limit to avoid modulo bias */ + while (UNEXPECTED(result > limit)) { + php_rng_next64(&result, obj); + } + + return result % umax; +} +#endif + +PHPAPI zend_long php_rng_range(zval *obj, zend_long min, zend_long max) +{ + /* Checking object defined range implementation. */ + if (Z_OBJCE_P(obj)->type == ZEND_INTERNAL_CLASS) { + php_rng *rng = Z_RNG_P(obj); + if (rng->range) { + return rng->range(rng); + } + } + + /* The implementation is stolen from php_mt_rand_range() */ + zend_ulong umax = max - min; + +#if ZEND_ULONG_MAX > UINT32_MAX + if (umax > UINT32_MAX) { + return (zend_long) (rng_rand_range64(obj, umax) + min); + } +#endif + + return (zend_long) (rng_rand_range32(obj, umax) + min); +} + +PHP_FUNCTION(rng_rand) +{ + zval *zrng; + zend_long min, max; + + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_OBJECT_OF_CLASS(zrng, rng_ce_RNG_RNGInterface) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(min) + Z_PARAM_LONG(max) + ZEND_PARSE_PARAMETERS_END(); + + if (ZEND_NUM_ARGS() == 1) { + uint32_t result; + + php_rng_next(&result, zrng); + RETURN_LONG((zend_long) (result >> 1)); + } + + if (UNEXPECTED(max < min)) { + zend_argument_value_error(2, "must be greater than or equal to argument #1 ($min)"); + RETURN_THROWS(); + } + + RETURN_LONG(php_rng_range(zrng, min, max)); +} + +PHP_FUNCTION(rng_bytes) +{ + zval *zrng; + zend_long size; + zend_string *result; + uint32_t buf; + uint8_t *bytes; + size_t generated_bytes = 0; + int i; + + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(zrng, rng_ce_RNG_RNGInterface) + Z_PARAM_LONG(size) + ZEND_PARSE_PARAMETERS_END(); + + if (size < 1) { + zend_argument_value_error(1, "must be greater than 0"); + RETURN_THROWS(); + } + + result = zend_string_alloc(size, 0); + + while (generated_bytes <= size) { + php_rng_next(&buf, zrng); + bytes = (uint8_t *) &buf; + for (i = 0; i < (sizeof(uint32_t) / sizeof(uint8_t)); i ++) { + ZSTR_VAL(result)[generated_bytes + i] = bytes[i]; + if ((generated_bytes + i) >= size) { + ZSTR_VAL(result)[size] = '\0'; + RETURN_STR(result); + } + } + generated_bytes += (sizeof(uint32_t) / sizeof(uint8_t)); + } +} + +PHP_MINIT_FUNCTION(rng) +{ + zend_class_entry ce_rng, ce_rng64; + + INIT_CLASS_ENTRY(ce_rng, RNG_NAMESPACE "RNGInterface", class_RNG_RNGInterface_methods); + rng_ce_RNG_RNGInterface = zend_register_internal_interface(&ce_rng); + + INIT_CLASS_ENTRY(ce_rng64, RNG_NAMESPACE "RNG64Interface", class_RNG_RNG64Interface_methods); + rng_ce_RNG_RNG64Interface = zend_register_internal_interface(&ce_rng64); + zend_class_implements(rng_ce_RNG_RNG64Interface, 1, rng_ce_RNG_RNGInterface); + + PHP_MINIT(rng_xorshift128plus)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(rng_mt19937)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(rng_osrng)(INIT_FUNC_ARGS_PASSTHRU); + + return SUCCESS; +} diff --git a/ext/standard/rng_mt19937.c b/ext/standard/rng_mt19937.c new file mode 100644 index 0000000000000..798d6171f492f --- /dev/null +++ b/ext/standard/rng_mt19937.c @@ -0,0 +1,272 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Go Kudo | + +----------------------------------------------------------------------+ +*/ + +/* + The following functions are based on a C++ class MTRand by + Richard J. Wagner. For more information see the web page at + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/MersenneTwister.h + + Mersenne Twister random number generator -- a C++ class MTRand + Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus + Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com + + The Mersenne Twister is an algorithm for generating random numbers. It + was designed with consideration of the flaws in various other generators. + The period, 2^19937-1, and the order of equidistribution, 623 dimensions, + are far greater. The generator is also fast; it avoids multiplication and + division, and it benefits from caches and pipelines. For more information + see the inventors' web page at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + + Reference + M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally + Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on + Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + Copyright (C) 2000 - 2003, Richard J. Wagner + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "php.h" +#include "php_rng.h" + +#include "zend_exceptions.h" + +#include "rng_mt19937.h" +#include "rng_mt19937_arginfo.h" + +PHPAPI zend_class_entry *rng_ce_RNG_MT19937; + +static zend_object_handlers MT19937_handlers; + +static inline void reload(rng_mt19937_state *state) +{ + uint32_t *p = state->s; + int i; + + for (i = MT19937_N - MT19937_M; i--; ++p) { + *p = MT19937_twist(p[MT19937_M], p[0], p[1]); + } + for (i = MT19937_M; --i; ++p) { + *p = MT19937_twist(p[MT19937_M-MT19937_N], p[0], p[1]); + } + *p = MT19937_twist(p[MT19937_M-MT19937_N], p[0], state->s[0]); + + state->i = 0; +} + +static uint32_t next(php_rng *rng) +{ + rng_mt19937_state *state = rng->state; + uint32_t s1; + + if (state->i >= MT19937_N) { + reload(state); + } + + s1 = state->s[state->i++]; + s1 ^= (s1 >> 11); + s1 ^= (s1 << 7) & 0x9d2c5680U; + s1 ^= (s1 << 15) & 0xefc60000U; + return ( s1 ^ (s1 >> 18) ); +} + +static zend_object *rng_object_new(zend_class_entry *ce) +{ + php_rng *rng = php_rng_initialize(next, NULL); + rng->state = (rng_mt19937_state*)ecalloc(1, sizeof(rng_mt19937_state)); + zend_object_std_init(&rng->std, ce); + rng->std.handlers = &MT19937_handlers; + + return &rng->std; +} + +static void free_object_storage(zend_object *object) +{ + php_rng *rng = rng_from_obj(object); + zend_object_std_dtor(&rng->std); + if (rng->state != NULL) { + efree(rng->state); + } +} + +static zend_object *rng_clone_obj(zend_object *object) +{ + zend_object *new_obj; + php_rng *new, *old; + + new_obj = rng_object_new(object->ce); + + zend_objects_clone_members(new_obj, object); + + new = rng_from_obj(new_obj); + old = rng_from_obj(object); + + memcpy(new->state, old->state, sizeof(rng_mt19937_state)); + + return new_obj; +} + +PHP_METHOD(RNG_MT19937, __construct) +{ + zend_long seed; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(seed); + ZEND_PARSE_PARAMETERS_END(); + + php_rng *rng = Z_RNG_P(ZEND_THIS); + rng_mt19937_state *state = rng->state; + + state->s[0] = seed & 0xffffffffU; + for (state->i = 1; state->i < MT19937_N; state->i++) { + state->s[state->i] = (1812433253U * (state->s[state->i - 1] ^ (state->s[state->i - 1] >> 30)) + state->i) & 0xffffffffU; + } + reload(state); +} + +PHP_METHOD(RNG_MT19937, next) +{ + php_rng *rng = Z_RNG_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_LONG((zend_long) rng->next(rng)); +} + +PHP_METHOD(RNG_MT19937, next64) +{ + php_rng *rng = Z_RNG_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_NONE(); + +#if UINT32_MAX >= ZEND_ULONG_MAX + zend_value_error("Method doesn't supported 32bit integer range."); + RETURN_THROWS(); +#endif + + uint64_t result = rng->next(rng); + result = (result << 32) | rng->next(rng); + + RETURN_LONG((zend_long) result); +} + +PHP_METHOD(RNG_MT19937, __serialize) +{ + php_rng *intern = Z_RNG_P(ZEND_THIS); + rng_mt19937_state *state = (rng_mt19937_state*) intern->state; + zval tmp; + int i; + + ZEND_PARSE_PARAMETERS_NONE(); + + array_init(return_value); + + /* state */ + for (i = 0; i < MT19937_N + 1; i++) { + ZVAL_LONG(&tmp,state->s[i]); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp); + } + ZVAL_LONG(&tmp, state->i); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp); + + /* members */ + ZVAL_ARR(&tmp, zend_std_get_properties(&intern->std)); + Z_TRY_ADDREF(tmp); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp); +} + +PHP_METHOD(RNG_MT19937, __unserialize) +{ + php_rng *intern = Z_RNG_P(ZEND_THIS); + rng_mt19937_state *state = (rng_mt19937_state*) intern->state; + HashTable *data; + zval *tmp, *members_zv; + int i; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &data) == FAILURE) { + RETURN_THROWS(); + } + + /* state */ + for (i = 0; i < MT19937_N + 1; i++) { + tmp = zend_hash_index_find(data, i); + if (Z_TYPE_P(tmp) != IS_LONG) { + zend_throw_exception(NULL, "Incomplete or ill-formed serialization data", 0); + RETURN_THROWS(); + } + + state->s[i] = Z_LVAL_P(tmp); + } + tmp = zend_hash_index_find(data, MT19937_N + 1); + if (Z_TYPE_P(tmp) != IS_LONG) { + zend_throw_exception(NULL, "Incomplete or ill-formed serialization data", 0); + RETURN_THROWS(); + } + state->i = Z_LVAL_P(tmp); + + /* members */ + members_zv = zend_hash_index_find(data, MT19937_N + 2); + if (!members_zv || Z_TYPE_P(members_zv) != IS_ARRAY || state->i < 0) { + zend_throw_exception(NULL, "Incomplete or ill-formed serialization data", 0); + RETURN_THROWS(); + } + + object_properties_load(&intern->std, Z_ARRVAL_P(members_zv)); +} + +PHP_MINIT_FUNCTION(rng_mt19937) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "MT19937", class_RNG_MT19937_methods); + rng_ce_RNG_MT19937 = zend_register_internal_class(&ce); + zend_class_implements(rng_ce_RNG_MT19937, 1, rng_ce_RNG_RNG64Interface); + rng_ce_RNG_MT19937->create_object = rng_object_new; + memcpy(&MT19937_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + MT19937_handlers.offset = XtOffsetOf(php_rng, std); + MT19937_handlers.free_obj = free_object_storage; + MT19937_handlers.clone_obj = rng_clone_obj; + + return SUCCESS; +} diff --git a/ext/standard/rng_mt19937.h b/ext/standard/rng_mt19937.h new file mode 100644 index 0000000000000..cf0e08e4759c9 --- /dev/null +++ b/ext/standard/rng_mt19937.h @@ -0,0 +1,96 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Go Kudo | + +----------------------------------------------------------------------+ +*/ + +/* + The following functions are based on a C++ class MTRand by + Richard J. Wagner. For more information see the web page at + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/MersenneTwister.h + + Mersenne Twister random number generator -- a C++ class MTRand + Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus + Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com + + The Mersenne Twister is an algorithm for generating random numbers. It + was designed with consideration of the flaws in various other generators. + The period, 2^19937-1, and the order of equidistribution, 623 dimensions, + are far greater. The generator is also fast; it avoids multiplication and + division, and it benefits from caches and pipelines. For more information + see the inventors' web page at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + + Reference + M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally + Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on + Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + Copyright (C) 2000 - 2003, Richard J. Wagner + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _RNG_MT19937_H +#define _RNG_MT19937_H + +#include "php.h" +#include "php_rng.h" + +/* stolen from mt_rand.c */ + +#define MT19937_N (624) +#define MT19937_M (397) + +#define MT19937_hiBit(u) ((u) & 0x80000000U) +#define MT19937_loBit(u) ((u) & 0x00000001U) +#define MT19937_loBits(u) ((u) & 0x7FFFFFFFU) +#define MT19937_MixBits(u, v) (MT19937_hiBit(u)|MT19937_loBits(v)) +#define MT19937_twist(m,u,v) (m ^ (MT19937_MixBits(u,v)>>1) ^ ((uint32_t)(-(int32_t)(MT19937_loBit(v))) & 0x9908b0dfU)) + +extern PHPAPI zend_class_entry *rng_ce_RNG_MT19937; + +typedef struct _rng_mt19937_state { + uint32_t s[MT19937_N + 1]; + int i; +} rng_mt19937_state; + +PHP_MINIT_FUNCTION(rng_mt19937); + +#endif diff --git a/ext/standard/rng_mt19937.stub.php b/ext/standard/rng_mt19937.stub.php new file mode 100644 index 0000000000000..263f2390cfb6c --- /dev/null +++ b/ext/standard/rng_mt19937.stub.php @@ -0,0 +1,15 @@ + | + +----------------------------------------------------------------------+ +*/ + +#include "php.h" +#include "php_random.h" +#include "php_rng.h" + +#include "zend_exceptions.h" + +#include "rng_osrng.h" +#include "rng_osrng_arginfo.h" + +PHPAPI zend_class_entry *rng_ce_RNG_OSRNG; + +static zend_object_handlers OSRNG_handlers; + +static uint32_t next(php_rng *rng) +{ + uint32_t buf; + php_random_bytes_silent(&buf, sizeof(uint32_t)); + return buf; +} + +static uint64_t next64(php_rng *rng) +{ + uint64_t buf; + php_random_bytes_silent(&buf, sizeof(uint64_t)); + return buf; +} + +static zend_object *rng_object_new(zend_class_entry *ce) +{ + php_rng *rng = php_rng_initialize(next, next64); + zend_object_std_init(&rng->std, ce); + object_properties_init(&rng->std, ce); + rng->std.handlers = &OSRNG_handlers; + + return &rng->std; +} + +static void free_object_storage(zend_object *object) +{ + php_rng *rng = rng_from_obj(object); + zend_object_std_dtor(&rng->std); +} + +PHP_METHOD(RNG_OSRNG, next) +{ + php_rng *rng = Z_RNG_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_LONG((zend_long) rng->next(rng)); +} + +PHP_METHOD(RNG_OSRNG, next64) +{ + php_rng *rng = Z_RNG_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_NONE(); + +#if UINT32_MAX >= ZEND_ULONG_MAX + zend_value_error("Method doesn't supported 32bit integer range."); + RETURN_THROWS(); +#endif + + RETURN_LONG((zend_long) rng->next64(rng)); +} + +PHP_MINIT_FUNCTION(rng_osrng) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "OSRNG", class_RNG_OSRNG_methods); + rng_ce_RNG_OSRNG = zend_register_internal_class(&ce); + zend_class_implements(rng_ce_RNG_OSRNG, 1, rng_ce_RNG_RNG64Interface); + rng_ce_RNG_OSRNG->create_object = rng_object_new; + memcpy(&OSRNG_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + OSRNG_handlers.offset = XtOffsetOf(php_rng, std); + OSRNG_handlers.free_obj = free_object_storage; + + return SUCCESS; +} diff --git a/ext/standard/rng_osrng.h b/ext/standard/rng_osrng.h new file mode 100644 index 0000000000000..a76c234cb1cce --- /dev/null +++ b/ext/standard/rng_osrng.h @@ -0,0 +1,26 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Go Kudo | + +----------------------------------------------------------------------+ +*/ +#ifndef _RNG_OSRNG_H +#define _RNG_OSRNG_H + +#include "php.h" +#include "php_rng.h" + +extern PHPAPI zend_class_entry *rng_ce_RNG_OSRNG; + +PHP_MINIT_FUNCTION(rng_osrng); + +#endif diff --git a/ext/standard/rng_osrng.stub.php b/ext/standard/rng_osrng.stub.php new file mode 100644 index 0000000000000..d6561d97d94bb --- /dev/null +++ b/ext/standard/rng_osrng.stub.php @@ -0,0 +1,12 @@ + | + +----------------------------------------------------------------------+ +*/ + +#include "php.h" +#include "php_rng.h" + +#include "zend_exceptions.h" + +#include "rng_xorshift128plus.h" +#include "rng_xorshift128plus_arginfo.h" + +PHPAPI zend_class_entry *rng_ce_RNG_XorShift128Plus; + +static zend_object_handlers XorShift128Plus_handlers; + +static uint64_t splitmix64(uint64_t *seed) +{ + uint64_t r; + r = (*seed += UINT64_C(0x9e3779b97f4a7c15)); + r = (r ^ (r >> 30)) * UINT64_C(0xbf58476d1ce4e5b9); + r = (r ^ (r >> 27)) * UINT64_C(0x94d049bb133111eb); + return (r ^ (r >> 31)); +} + +static uint32_t next(php_rng *rng) +{ + return (uint32_t) (rng->next64(rng)); +} + +static uint64_t next64(php_rng *rng) +{ + uint64_t s0, s1, r; + + rng_xorshift128plus_state *state = (rng_xorshift128plus_state*) rng->state; + + s1 = state->s[0]; + s0 = state->s[1]; + r = s0 + s1; + state->s[0] = s0; + s1 ^= s1 << 23; + state->s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5); + + return r; +} + +static zend_object *rng_object_new(zend_class_entry *ce) +{ + php_rng *rng = php_rng_initialize(next, next64); + rng->state = (rng_xorshift128plus_state*)ecalloc(1, sizeof(rng_xorshift128plus_state)); + zend_object_std_init(&rng->std, ce); + object_properties_init(&rng->std, ce); + rng->std.handlers = &XorShift128Plus_handlers; + + return &rng->std; +} + +static void free_object_storage(zend_object *object) +{ + php_rng *rng = rng_from_obj(object); + zend_object_std_dtor(&rng->std); + if (rng->state != NULL) { + efree(rng->state); + } +} + +static zend_object *rng_clone_obj(zend_object *object) +{ + zend_object *new_obj; + php_rng *new, *old; + + new_obj = rng_object_new(object->ce); + + zend_objects_clone_members(new_obj, object); + + new = rng_from_obj(new_obj); + old = rng_from_obj(object); + + memcpy(new->state, old->state, sizeof(rng_xorshift128plus_state)); + + return new_obj; +} + +PHP_METHOD(RNG_XorShift128Plus, __construct) +{ + zend_long seed; + uint64_t s; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(seed); + ZEND_PARSE_PARAMETERS_END(); + + php_rng *rng = Z_RNG_P(ZEND_THIS); + rng_xorshift128plus_state *state = rng->state; + + s = (uint64_t) seed; + state->s[0] = splitmix64(&s); + state->s[1] = splitmix64(&s); +} + +PHP_METHOD(RNG_XorShift128Plus, next) +{ + php_rng *rng = Z_RNG_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_LONG((zend_long) rng->next(rng)); +} + +PHP_METHOD(RNG_XorShift128Plus, next64) +{ + php_rng *rng = Z_RNG_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_NONE(); + +#if UINT32_MAX >= ZEND_ULONG_MAX + zend_value_error("Method doesn't supported 32bit integer range."); + RETURN_THROWS(); +#endif + + RETURN_LONG((zend_long) rng->next64(rng)); +} + +PHP_METHOD(RNG_XorShift128Plus, __serialize) +{ + php_rng *intern = Z_RNG_P(ZEND_THIS); + rng_xorshift128plus_state *state = (rng_xorshift128plus_state*) intern->state; + zval tmp; + int i; + + ZEND_PARSE_PARAMETERS_NONE(); + + array_init(return_value); + + /* state */ + for (i = 0; i < XORSHIFT128PLUS_N; i++) { + ZVAL_STR(&tmp, zend_strpprintf(0, "%" PRIu64, state->s[i])); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp); + } + + /* members */ + ZVAL_ARR(&tmp, zend_std_get_properties(&intern->std)); + Z_TRY_ADDREF(tmp); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp); +} + +PHP_METHOD(RNG_XorShift128Plus, __unserialize) +{ + php_rng *intern = Z_RNG_P(ZEND_THIS); + rng_xorshift128plus_state *state = (rng_xorshift128plus_state*) intern->state; + HashTable *data; + zval *tmp, *members_zv; + int i; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &data) == FAILURE) { + RETURN_THROWS(); + } + + /* state */ + for (i = 0; i < XORSHIFT128PLUS_N; i++) { + tmp = zend_hash_index_find(data, i); + if (Z_TYPE_P(tmp) != IS_STRING) { + zend_throw_exception(NULL, "Incomplete or ill-formed serialization data", 0); + RETURN_THROWS(); + } + + state->s[i] = strtoull(ZSTR_VAL(Z_STR_P(tmp)), NULL, 10); + } + + /* members */ + members_zv = zend_hash_index_find(data, XORSHIFT128PLUS_N); + if (!members_zv || Z_TYPE_P(members_zv) != IS_ARRAY || (state->s[0] == 0 && state->s[1] == 0)) { + zend_throw_exception(NULL, "Incomplete or ill-formed serialization data", 0); + RETURN_THROWS(); + } + + object_properties_load(&intern->std, Z_ARRVAL_P(members_zv)); +} + +PHP_MINIT_FUNCTION(rng_xorshift128plus) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "XorShift128Plus", class_RNG_XorShift128Plus_methods); + rng_ce_RNG_XorShift128Plus = zend_register_internal_class(&ce); + zend_class_implements(rng_ce_RNG_XorShift128Plus, 1, rng_ce_RNG_RNG64Interface); + rng_ce_RNG_XorShift128Plus->create_object = rng_object_new; + memcpy(&XorShift128Plus_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + XorShift128Plus_handlers.offset = XtOffsetOf(php_rng, std); + XorShift128Plus_handlers.free_obj = free_object_storage; + XorShift128Plus_handlers.clone_obj = rng_clone_obj; + + return SUCCESS; +} diff --git a/ext/standard/rng_xorshift128plus.h b/ext/standard/rng_xorshift128plus.h new file mode 100644 index 0000000000000..ac8fc50d67bf5 --- /dev/null +++ b/ext/standard/rng_xorshift128plus.h @@ -0,0 +1,32 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Go Kudo | + +----------------------------------------------------------------------+ +*/ +#ifndef _RNG_XORSHIFT128PLUS_H +#define _RNG_XORSHIFT128PLUS_H + +#include "php.h" +#include "php_rng.h" + +extern PHPAPI zend_class_entry *rng_ce_RNG_XorShift128Plus; + +#define XORSHIFT128PLUS_N 2 + +typedef struct _rng_xorshift128plus_state { + uint64_t s[XORSHIFT128PLUS_N]; +} rng_xorshift128plus_state; + +PHP_MINIT_FUNCTION(rng_xorshift128plus); + +#endif diff --git a/ext/standard/rng_xorshift128plus.stub.php b/ext/standard/rng_xorshift128plus.stub.php new file mode 100644 index 0000000000000..fee1f1cadd97d --- /dev/null +++ b/ext/standard/rng_xorshift128plus.stub.php @@ -0,0 +1,15 @@ + #include "php.h" #include "php_rand.h" +#include "php_rng.h" #include "php_string.h" #include "php_variables.h" #include @@ -5714,7 +5715,7 @@ PHP_FUNCTION(str_rot13) } /* }}} */ -static void php_string_shuffle(char *str, zend_long len) /* {{{ */ +static void php_string_shuffle(char *str, zend_long len, zval *zrng) /* {{{ */ { zend_long n_elems, rnd_idx, n_left; char temp; @@ -5729,7 +5730,7 @@ static void php_string_shuffle(char *str, zend_long len) /* {{{ */ n_left = n_elems; while (--n_left) { - rnd_idx = php_mt_rand_range(0, n_left); + rnd_idx = zrng ? php_rng_range(zrng, 0, n_left) : php_mt_rand_range(0, n_left); if (rnd_idx != n_left) { temp = str[n_left]; str[n_left] = str[rnd_idx]; @@ -5742,15 +5743,18 @@ static void php_string_shuffle(char *str, zend_long len) /* {{{ */ /* {{{ Shuffles string. One permutation of all possible is created */ PHP_FUNCTION(str_shuffle) { + zval *zrng = NULL; zend_string *arg; - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STR(arg) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(zrng, rng_ce_RNG_RNGInterface) ZEND_PARSE_PARAMETERS_END(); RETVAL_STRINGL(ZSTR_VAL(arg), ZSTR_LEN(arg)); if (Z_STRLEN_P(return_value) > 1) { - php_string_shuffle(Z_STRVAL_P(return_value), (zend_long) Z_STRLEN_P(return_value)); + php_string_shuffle(Z_STRVAL_P(return_value), (zend_long) Z_STRLEN_P(return_value), zrng); } } /* }}} */ diff --git a/ext/standard/tests/rng/_clonable_rng_classes.inc b/ext/standard/tests/rng/_clonable_rng_classes.inc new file mode 100644 index 0000000000000..53a6d34b715d1 --- /dev/null +++ b/ext/standard/tests/rng/_clonable_rng_classes.inc @@ -0,0 +1,5 @@ + true, + '\\RNG\\MT19937' => true, +]; diff --git a/ext/standard/tests/rng/_rng_classes.inc b/ext/standard/tests/rng/_rng_classes.inc new file mode 100644 index 0000000000000..d13657456caf5 --- /dev/null +++ b/ext/standard/tests/rng/_rng_classes.inc @@ -0,0 +1,6 @@ + true, + '\\RNG\\MT19937' => true, + '\\RNG\\OSRNG' => false, +]; diff --git a/ext/standard/tests/rng/_serializable_rng_classes.inc b/ext/standard/tests/rng/_serializable_rng_classes.inc new file mode 100644 index 0000000000000..53a6d34b715d1 --- /dev/null +++ b/ext/standard/tests/rng/_serializable_rng_classes.inc @@ -0,0 +1,5 @@ + true, + '\\RNG\\MT19937' => true, +]; diff --git a/ext/standard/tests/rng/class_clone.phpt b/ext/standard/tests/rng/class_clone.phpt new file mode 100644 index 0000000000000..3b544c34504e4 --- /dev/null +++ b/ext/standard/tests/rng/class_clone.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test class: clone RNG classes. +--FILE-- + $is_seed) { + $rng1 = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $rng1->next(); + + $rng2 = clone $rng1; + + $rng1_value = $rng1->next(); + $rng2_value = $rng2->next(); + + if ($rng1_value !== $rng2_value) { + die("NG, state is not cloned. RNG class: ${class} RNG1 value: ${rng1_value} RNG2 value: ${rng2_value}"); + } +} +die('OK, clone is corrected.'); +?> +--EXPECT-- +OK, clone is corrected. diff --git a/ext/standard/tests/rng/class_inheritance.phpt b/ext/standard/tests/rng/class_inheritance.phpt new file mode 100644 index 0000000000000..c2cc98a1e8776 --- /dev/null +++ b/ext/standard/tests/rng/class_inheritance.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test class: inheritance classes. +--FILE-- + $is_seed) { + $rng = $is_seed ? new $class(SEED) : new $class(); + if (! $rng instanceof \RNG\RNGInterface) { + die("NG, ${class} has not implemented \\RNG\\RNGInterface."); + } + if (! $rng instanceof \RNG\RNG64Interface) { + die("NG, ${class} has not implemented \\RNG\\RNG64Interface."); + } +} + +die('OK, inheritance is corrected.'); +?> +--EXPECT-- +OK, inheritance is corrected. diff --git a/ext/standard/tests/rng/class_serialize.phpt b/ext/standard/tests/rng/class_serialize.phpt new file mode 100644 index 0000000000000..a4a5bff10cef6 --- /dev/null +++ b/ext/standard/tests/rng/class_serialize.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test class: serialize in supported RNG classes. +--FILE-- + $is_seed) { + $e = explode('\\', $class); + $define_class = 'X' . end($e); + eval("class ${define_class} extends ${class} { public \$foo; public \$bar; public \$baz; }"); + $t = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $t->foo = 'bar'; + $t->bar = 1234; + $t->baz = [1, 2, 3, 4]; + $t->next(); + + $s = serialize($t); + $t_next = $t->next(); + $ut = unserialize($s); + $ut_next = $ut->next(); + if ($ut_next !== $t_next) { + die("NG, broken detected. class: ${class} method: next() correct: ${t_next} result: ${ut_next}"); + } + if ($ut->foo !== 'bar' || + $ut->bar !== 1234 || + $ut->baz[0] !== 1 || + $ut->baz[1] !== 2 || + $ut->baz[2] !== 3 || + $ut->baz[3] !== 4 + ) { + die('NG, broken detected in properties: ' . print_r($ut, true)); + } +} +die('OK, serialize / unserialize works correctly.'); +?> +--EXPECT-- +OK, serialize / unserialize works correctly. diff --git a/ext/standard/tests/rng/class_serialize_64.phpt b/ext/standard/tests/rng/class_serialize_64.phpt new file mode 100644 index 0000000000000..fedea6d10a41f --- /dev/null +++ b/ext/standard/tests/rng/class_serialize_64.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test class: serialize in supported RNG classes in 64bit range. +--SKIPIF-- + +--FILE-- + $is_seed) { + $e = explode('\\', $class); + $define_class = 'X' . end($e); + eval("class ${define_class} extends ${class} { public \$foo; public \$bar; public \$baz; }"); + $t = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $t->foo = 'bar'; + $t->bar = 1234; + $t->baz = [1, 2, 3, 4]; + $t->next(); + + $s = serialize($t); + $t_next64 = $t->next64(); + $ut = unserialize($s); + $ut_next64 = $ut->next64(); + if ($ut_next64 !== $t_next64) { + die("NG, broken detected. class: ${class} method: next64() correct: ${t_next64} result: ${ut_next64}"); + } + if ($ut->foo !== 'bar' || + $ut->bar !== 1234 || + $ut->baz[0] !== 1 || + $ut->baz[1] !== 2 || + $ut->baz[2] !== 3 || + $ut->baz[3] !== 4 + ) { + die('NG, broken detected in properties: ' . print_r($ut, true)); + } +} +die('OK, serialize / unserialize works correctly.'); +?> +--EXPECT-- +OK, serialize / unserialize works correctly. diff --git a/ext/standard/tests/rng/class_userland.phpt b/ext/standard/tests/rng/class_userland.phpt new file mode 100644 index 0000000000000..95f15333cd40e --- /dev/null +++ b/ext/standard/tests/rng/class_userland.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test class: userland implemented classes. +--FILE-- +count++; + } + + public function next64(): int + { + return $this->count++ * 2; + } +} + +$rng = new FixedNumberGenerator(); +$array = range(1, 100); + +$rng->next() . PHP_EOL; +$rng->next64() . PHP_EOL; +array_rand($array, 1, $rng); +array_rand($array, 2, $rng); +shuffle($array, $rng); +str_shuffle('foobar', $rng); +rng_rand($rng, 1, 1000) . PHP_EOL; +rng_bytes($rng, 100) . PHP_EOL; + +class XorShift128PlusEx extends \RNG\XorShift128Plus +{ + public function next(): int + { + return parent::next() + 1; + } + + public function next64(): int + { + return parent::next() + 1; + } +} + +$origin = new \RNG\XorShift128Plus(12345); +$extend = new XorShift128PlusEx(12345); + +for ($i = 0; $i < 100000; $i++) { + $origin_next = $origin->next(); + $extend_next = $extend->next(); + + if (($origin_next + 1) !== $extend_next) { + die("NG, userland extended class is broken."); + } +} + +die('OK, userland implementation works correctly.'); +?> +--EXPECT-- +OK, userland implementation works correctly. diff --git a/ext/standard/tests/rng/class_userland_extend.phpt b/ext/standard/tests/rng/class_userland_extend.phpt new file mode 100644 index 0000000000000..84d7c6e034a3d --- /dev/null +++ b/ext/standard/tests/rng/class_userland_extend.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test class: userland implemented extended classes. +--FILE-- +next(); + $extend_next = $extend->next(); + + if (($origin_next + 1) !== $extend_next) { + die("NG, userland extended class is broken."); + } +} + +die('OK, userland implementation extended class works correctly.'); +?> +--EXPECT-- +OK, userland implementation extended class works correctly. diff --git a/ext/standard/tests/rng/function_array_rand.phpt b/ext/standard/tests/rng/function_array_rand.phpt new file mode 100644 index 0000000000000..e056f557a3479 --- /dev/null +++ b/ext/standard/tests/rng/function_array_rand.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function: array_rand() function with RNGs. +--FILE-- + 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25]; +// one key +foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { + $rng = $is_seed ? new $class(SEED) : new $class(); + foreach ($array as $key => $value) { + if (array_rand($array, 1, $rng) !== $key) { + continue 2; + } + } + die("NG, Failed get randomize key. RNG class: ${class}"); +} +// more keys. +foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { + $rng = $is_seed ? new $class(SEED) : new $class(); + [$key1, $key2] = array_rand($array, 2, $rng); + if ( + ! array_key_exists($key1, $array) || + ! array_key_exists($key2, $array) || + ($key1 === 'a' && $key2 === 'b') + ) { + die("NG, Failed get multiple random keys. RNG class: ${class}"); + } +} +die('OK, All works correctly.'); +?> +--EXPECT-- +OK, All works correctly. diff --git a/ext/standard/tests/rng/function_rng_bytes.phpt b/ext/standard/tests/rng/function_rng_bytes.phpt new file mode 100644 index 0000000000000..ca7f733cbf555 --- /dev/null +++ b/ext/standard/tests/rng/function_rng_bytes.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test function: rng_bytes() function. +--FILE-- + $is_seed) { + $rng = $is_seed ? new $class(SEED) : new $class(); + foreach (range(0, 999) as $i) { + $next = rng_bytes($rng, 100); + + if (strlen($next) !== 100) { + die("NG, invalid bytes: ${next}."); + } + } +} +die('OK, rng_bytes() works correctly.'); +?> +--EXPECT-- +OK, rng_bytes() works correctly. diff --git a/ext/standard/tests/rng/function_rng_bytes_string.phpt b/ext/standard/tests/rng/function_rng_bytes_string.phpt new file mode 100644 index 0000000000000..a7a7771307ef9 --- /dev/null +++ b/ext/standard/tests/rng/function_rng_bytes_string.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test function: rng_bytes() generate strings. +--FILE-- +cnt}"; + $this->cnt++; + return $this->$method(); + } + + private function gen0(): int + { + $t = ord('l'); + $t = $t << 8 | ord('l'); + $t = $t << 8 | ord('e'); + $t = $t << 8 | ord('H'); + return $t; + } + + private function gen1(): int + { + $t = ord('o'); + $t = $t << 8 | ord("w"); + $t = $t << 8 | ord(' '); + $t = $t << 8 | ord('o'); + return $t; + } + + private function gen2(): int + { + $t = ord('.'); + $t = $t << 8 | ord('d'); + $t = $t << 8 | ord('l'); + $t = $t << 8 | ord('r'); + return $t; + } + + private function gen3(): int + { + return 0; + } +} + +$result = rng_bytes(new StringGenerator(), 12); +if ($result !== 'Hello world.') { + die("NG, rng_bytes() invalid result: ${result}"); +} + +$result = rng_bytes(new StringGenerator(), 4); +if ($result !== 'Hell') { + die("NG, rng_bytes() invalid result: ${result}"); +} + +$result = rng_bytes(new StringGenerator(), 2); +if ($result !== 'He') { + die("NG, rng_bytes() invalid result: ${result}"); +} + +die('OK, rng_bytes() works correctly.'); +?> +--EXPECT-- +OK, rng_bytes() works correctly. diff --git a/ext/standard/tests/rng/function_rng_rand.phpt b/ext/standard/tests/rng/function_rng_rand.phpt new file mode 100644 index 0000000000000..dd033181ca76e --- /dev/null +++ b/ext/standard/tests/rng/function_rng_rand.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test function: rng_rand() function. +--FILE-- + $is_seed) { + $rng = $is_seed ? new $class(SEED) : new $class(); + foreach (range(0, 999) as $i) { + $next = rng_rand($rng, 1, 10000); + + if ($next < 0 || $next > 10000) { + die("NG, invalid number: ${next}."); + } + } +} +die('OK, rng_rand() works correctly.'); +?> +--EXPECT-- +OK, rng_rand() works correctly. diff --git a/ext/standard/tests/rng/function_rng_rand_64.phpt b/ext/standard/tests/rng/function_rng_rand_64.phpt new file mode 100644 index 0000000000000..59e33edf75fe6 --- /dev/null +++ b/ext/standard/tests/rng/function_rng_rand_64.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function: rng_rand() function in 64bit range. +--SKIPIF-- + +--FILE-- + $is_seed) { + $rng = $is_seed ? new $class(SEED) : new $class(); + foreach (range(0, 999) as $i) { + $next = rng_rand($rng, 4294967296, PHP_INT_MAX); + + if ($next < 4294967296) { + die("NG, invalid number: ${next}."); + } + } +} +die('OK, rng_rand() works correctly on 64bit.'); +?> +--EXPECT-- +OK, rng_rand() works correctly on 64bit. diff --git a/ext/standard/tests/rng/function_shuffle.phpt b/ext/standard/tests/rng/function_shuffle.phpt new file mode 100644 index 0000000000000..76808585d337f --- /dev/null +++ b/ext/standard/tests/rng/function_shuffle.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test function: shuffle() function with RNGs. +--FILE-- + $is_seed) { + $array = range(0, 999); + $rng = $is_seed ? new $class(SEED) : new $class(); + shuffle($array, $rng); + foreach (range(0, 999) as $i) { + foreach ($array as $key => $value) { + if ($key !== $i) { + break 2; + } + } + die("NG, Array not shuffled. RNG class: ${class}"); + } +} +die('OK, All array shuffled.'); +?> +--EXPECT-- +OK, All array shuffled. diff --git a/ext/standard/tests/rng/function_str_shuffle.phpt b/ext/standard/tests/rng/function_str_shuffle.phpt new file mode 100644 index 0000000000000..2e5ed9eed9333 --- /dev/null +++ b/ext/standard/tests/rng/function_str_shuffle.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function: str_shuffle() function with RNGs. +--FILE-- + $is_seed) { + $string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; + $rng = $is_seed ? new $class(SEED) : new $class(); + $shuffled_string = str_shuffle($string, $rng); + for ($i = 0; $i < strlen($string); $i++) { + if ($string[$i] !== $shuffled_string[$i]) { + continue 2; + } + } + die("NG, String not shuffled. RNG class: ${class} string: ${shuffled_string}"); +} +die('OK, All string shuffled.'); +?> +--EXPECT-- +OK, All string shuffled. diff --git a/ext/standard/tests/rng/method_next.phpt b/ext/standard/tests/rng/method_next.phpt new file mode 100644 index 0000000000000..fb6d3c5b8a7cd --- /dev/null +++ b/ext/standard/tests/rng/method_next.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test method: next() call. +--FILE-- + $is_seed) { + $rng = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + for ($i = 1; $i <= 10000; $i++) { + $next = $rng->next(); + } +} + +die('OK.'); +?> +--EXPECT-- +OK. diff --git a/ext/standard/tests/rng/method_next_64.phpt b/ext/standard/tests/rng/method_next_64.phpt new file mode 100644 index 0000000000000..de9de123ed200 --- /dev/null +++ b/ext/standard/tests/rng/method_next_64.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test method: next64() call. +--SKIPIF-- + +--FILE-- + $is_seed) { + $rng = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + for ($i = 1; $i <= 10000; $i++) { + $next = $rng->next64(); + } +} + +die('OK.'); +?> +--EXPECT-- +OK. diff --git a/ext/standard/tests/rng/mt19937_consistency.phpt b/ext/standard/tests/rng/mt19937_consistency.phpt new file mode 100644 index 0000000000000..5ae843b180d78 --- /dev/null +++ b/ext/standard/tests/rng/mt19937_consistency.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test class: MT19937: consistent for mt_srand() / mt_rand() +--FILE-- +next() >> 1 & PHP_INT_MAX); // virtually logical shift + $func_next = \mt_rand(); + + if ($rng_next !== $func_next) { + die("NG, Inconsistent result MT19937: ${rng_next} mt_rand: ${func_next} i: ${i} j: ${j}"); + } + } + // shuffle + $rng_array = range(0, 99); + $func_array = range(0, 99); + shuffle($rng_array, $rng); + shuffle($func_array); + for ($k = 0; $k < 100; $k++) { + if ($rng_array[$k] !== $func_array[$k]) { + die("NG, Incosistent result MT19937: {$rng_array[$k]} shuffle: {$func_array[$k]} i: ${i} k: ${k}"); + } + } + // str_shuffle + $rng_string = random_bytes(100); + $func_string = $rng_string; + $rng_string = str_shuffle($rng_string); + $func_string = str_shuffle($func_string, $rng); + for ($k = 0; $k < 100; $k++) { + if ($rng_string[$k] !== $func_string[$k]) { + die("NG, Incosistent result MT19937: {$rng_string[$k]} str_shuffle: {$func_string[$k]} i: ${i} k: ${k}"); + } + } + // array_rand (1 key) + $rng_data = ['a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25]; + $func_data = $rng_data; + for ($k = 0; $k < 26; $k++) { + $rng_result = array_rand($rng_data, 1, $rng); + $func_result = array_rand($func_data, 1); + if ($rng_result !== $func_result) { + die("NG, Incosistent result MT19937: {$rng_result} array_rand (1 key): {$func_result} i: ${i} k: ${k}"); + } + } + // array_rand (2 keys) + $rng_data = ['a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25]; + $func_data = $rng_data; + for ($k = 0; $k < 26; $k++) { + [$rng_result1, $rng_result2] = array_rand($rng_data, 2, $rng); + [$func_result1, $func_result2] = array_rand($func_data, 2); + if ($rng_result1 !== $func_result1 || $rng_result2 !== $func_result2) { + die("NG, Incosistent result MT19937: {$rng_result1} / ${rng_result2} array_rand (2 key): {$func_result1} / ${func_result2} i: ${i} k: ${k}"); + } + } +} +die('OK, Result is consistent.'); +?> +--EXPECT-- +OK, Result is consistent. diff --git a/ext/standard/tests/rng/mt19937_result.phpt b/ext/standard/tests/rng/mt19937_result.phpt new file mode 100644 index 0000000000000..5afc1eac54b70 --- /dev/null +++ b/ext/standard/tests/rng/mt19937_result.phpt @@ -0,0 +1,1021 @@ +--TEST-- +Test class: MT19937: consistent result. +--FILE-- + 1996335345, + 1 => 1911592690, + 2 => 679411342, + 3 => 280691776, + 4 => 394962642, + 5 => 85382868, + 6 => 439289855, + 7 => 1774758079, + 8 => 1219180210, + 9 => 1142628625, + 10 => 1278922510, + 11 => 2053660032, + 12 => 2071279163, + 13 => 991979192, + 14 => 1402687133, + 15 => 1983712583, + 16 => 1608264756, + 17 => 802989613, + 18 => 1403530619, + 19 => 332802747, + 20 => 1605705320, + 21 => 1916293561, + 22 => 2064390500, + 23 => 57530501, + 24 => 18013734, + 25 => 625996613, + 26 => 228587560, + 27 => 856296297, + 28 => 641461331, + 29 => 1733639299, + 30 => 1409632277, + 31 => 1346674803, + 32 => 1739059211, + 33 => 1949753870, + 34 => 1872983516, + 35 => 1194854107, + 36 => 2071564943, + 37 => 1803712862, + 38 => 1554102448, + 39 => 108422061, + 40 => 1379705259, + 41 => 1731376146, + 42 => 1540719904, + 43 => 1998911479, + 44 => 1004161217, + 45 => 781747582, + 46 => 699187774, + 47 => 1483799362, + 48 => 944129607, + 49 => 277700923, + 50 => 1566995365, + 51 => 1788180423, + 52 => 2134630073, + 53 => 683659432, + 54 => 1453575221, + 55 => 1583129794, + 56 => 1698278417, + 57 => 1281553050, + 58 => 367035577, + 59 => 781054500, + 60 => 57658370, + 61 => 1707186289, + 62 => 1718782006, + 63 => 1499976834, + 64 => 1940729373, + 65 => 1764971561, + 66 => 52991750, + 67 => 1931588295, + 68 => 1056019325, + 69 => 1786490152, + 70 => 1130124365, + 71 => 1954119315, + 72 => 1280686252, + 73 => 2093610992, + 74 => 111577973, + 75 => 1409006082, + 76 => 1922190117, + 77 => 1743734310, + 78 => 1563939723, + 79 => 220641030, + 80 => 1757393276, + 81 => 510088479, + 82 => 1074220180, + 83 => 814637641, + 84 => 1739868505, + 85 => 1501597993, + 86 => 206090844, + 87 => 1041411991, + 88 => 470191645, + 89 => 891682955, + 90 => 555594954, + 91 => 1371515779, + 92 => 1005249448, + 93 => 1630562847, + 94 => 986496445, + 95 => 1197271296, + 96 => 1523660653, + 97 => 1489184086, + 98 => 382365916, + 99 => 1961209031, + 100 => 1141279949, + 101 => 52855637, + 102 => 360223695, + 103 => 1798256241, + 104 => 1651015312, + 105 => 822926977, + 106 => 1993231072, + 107 => 641605891, + 108 => 1308877665, + 109 => 13522904, + 110 => 322516605, + 111 => 939647422, + 112 => 1051465334, + 113 => 1584708242, + 114 => 810342116, + 115 => 806939413, + 116 => 1822357663, + 117 => 1059245163, + 118 => 1956566410, + 119 => 30149920, + 120 => 824308848, + 121 => 535661442, + 122 => 677522301, + 123 => 745467252, + 124 => 1220617145, + 125 => 1710871612, + 126 => 403336159, + 127 => 2015197290, + 128 => 270242659, + 129 => 215869500, + 130 => 1476600738, + 131 => 1579265174, + 132 => 1717142345, + 133 => 2096882746, + 134 => 1231660388, + 135 => 1515878117, + 136 => 2089995465, + 137 => 2043899074, + 138 => 1361621406, + 139 => 1992537403, + 140 => 1907871122, + 141 => 880534724, + 142 => 1063895094, + 143 => 726053438, + 144 => 755090739, + 145 => 1651647648, + 146 => 1533798039, + 147 => 718651596, + 148 => 1082179541, + 149 => 177568250, + 150 => 484553056, + 151 => 1929639078, + 152 => 526078596, + 153 => 1690788548, + 154 => 1702526537, + 155 => 1540745527, + 156 => 1063374663, + 157 => 953461677, + 158 => 1965148688, + 159 => 1612528374, + 160 => 2030170553, + 161 => 1412825904, + 162 => 1145107499, + 163 => 774591522, + 164 => 542223721, + 165 => 812442407, + 166 => 1548039473, + 167 => 1395073934, + 168 => 789068739, + 169 => 119479170, + 170 => 1070839379, + 171 => 168060537, + 172 => 486566209, + 173 => 197360171, + 174 => 759276432, + 175 => 1728949882, + 176 => 1397693574, + 177 => 140246698, + 178 => 672018272, + 179 => 481722188, + 180 => 1650846806, + 181 => 326702722, + 182 => 1678982392, + 183 => 1461557823, + 184 => 1830535425, + 185 => 270494633, + 186 => 2039907052, + 187 => 552672344, + 188 => 230474196, + 189 => 940528337, + 190 => 1955767810, + 191 => 235509401, + 192 => 721672972, + 193 => 675525430, + 194 => 1774638452, + 195 => 753190951, + 196 => 1928656425, + 197 => 1634541854, + 198 => 91730430, + 199 => 212281301, + 200 => 420466551, + 201 => 2000295820, + 202 => 632436783, + 203 => 700249478, + 204 => 1346471996, + 205 => 916193093, + 206 => 185162715, + 207 => 581282930, + 208 => 306972086, + 209 => 1692452844, + 210 => 1107729012, + 211 => 973505804, + 212 => 1480349232, + 213 => 178747504, + 214 => 1839589934, + 215 => 151132959, + 216 => 1390198627, + 217 => 708131131, + 218 => 1249016605, + 219 => 412542585, + 220 => 1527109872, + 221 => 1799301990, + 222 => 542061074, + 223 => 132468299, + 224 => 1933078196, + 225 => 1190209990, + 226 => 949818473, + 227 => 1225378138, + 228 => 44068142, + 229 => 992374267, + 230 => 2060856320, + 231 => 2037594380, + 232 => 1400643424, + 233 => 740396381, + 234 => 1102102029, + 235 => 1899339932, + 236 => 1465349181, + 237 => 925651654, + 238 => 1051279981, + 239 => 2135629195, + 240 => 1989622494, + 241 => 1719068091, + 242 => 1107843375, + 243 => 2022143398, + 244 => 154962172, + 245 => 814926266, + 246 => 1218714786, + 247 => 870643160, + 248 => 1321224672, + 249 => 616086309, + 250 => 2021955279, + 251 => 967514529, + 252 => 891986005, + 253 => 1643063583, + 254 => 567880521, + 255 => 1245323967, + 256 => 209150232, + 257 => 812013180, + 258 => 1043342525, + 259 => 1336579417, + 260 => 997855902, + 261 => 1587361287, + 262 => 63907642, + 263 => 1961474865, + 264 => 1490949493, + 265 => 1142683784, + 266 => 1539632198, + 267 => 1112012871, + 268 => 1567258102, + 269 => 220304000, + 270 => 889812045, + 271 => 261283859, + 272 => 32424513, + 273 => 1382328063, + 274 => 1952009288, + 275 => 957701366, + 276 => 1695177900, + 277 => 163906647, + 278 => 354762518, + 279 => 327639909, + 280 => 671702737, + 281 => 170742068, + 282 => 1311995048, + 283 => 1888435622, + 284 => 782736935, + 285 => 346762443, + 286 => 335090308, + 287 => 1982021326, + 288 => 380757040, + 289 => 7686376, + 290 => 1863778878, + 291 => 1723574494, + 292 => 622973564, + 293 => 651832639, + 294 => 1256663673, + 295 => 525605718, + 296 => 974946563, + 297 => 1649720268, + 298 => 882998310, + 299 => 1510715837, + 300 => 1895443026, + 301 => 1903049045, + 302 => 1487579134, + 303 => 1960956657, + 304 => 599734964, + 305 => 483850882, + 306 => 138384344, + 307 => 905128946, + 308 => 426540963, + 309 => 356186468, + 310 => 2000773459, + 311 => 452764213, + 312 => 1834839152, + 313 => 1803667824, + 314 => 2050277231, + 315 => 1965914910, + 316 => 112213208, + 317 => 1463706528, + 318 => 1244405958, + 319 => 878872436, + 320 => 1031857880, + 321 => 477016953, + 322 => 46619669, + 323 => 1793793112, + 324 => 802343824, + 325 => 1668029770, + 326 => 889255366, + 327 => 1583437416, + 328 => 1296880906, + 329 => 1844048966, + 330 => 1442569393, + 331 => 2088452393, + 332 => 1801450375, + 333 => 880381190, + 334 => 1674019788, + 335 => 1282077735, + 336 => 860498936, + 337 => 1585792114, + 338 => 1706238535, + 339 => 572754394, + 340 => 1917969852, + 341 => 1638815766, + 342 => 563692314, + 343 => 1998239551, + 344 => 2124284393, + 345 => 1878379511, + 346 => 1832463051, + 347 => 249458974, + 348 => 1570835222, + 349 => 2077237809, + 350 => 763571372, + 351 => 650660577, + 352 => 1896849736, + 353 => 1307851524, + 354 => 1863927958, + 355 => 360255510, + 356 => 2052492807, + 357 => 1843455684, + 358 => 230320, + 359 => 1559915560, + 360 => 35521630, + 361 => 139838862, + 362 => 674460316, + 363 => 1112608131, + 364 => 2137425209, + 365 => 1278795651, + 366 => 319640533, + 367 => 983380113, + 368 => 359439627, + 369 => 1271829480, + 370 => 1629021052, + 371 => 686024941, + 372 => 149313815, + 373 => 1760575286, + 374 => 1514992675, + 375 => 199155381, + 376 => 1007524773, + 377 => 379825459, + 378 => 21879034, + 379 => 473976385, + 380 => 1663921582, + 381 => 1018107545, + 382 => 1705533665, + 383 => 1970212823, + 384 => 321197942, + 385 => 2129306733, + 386 => 50903158, + 387 => 1297540367, + 388 => 1636519480, + 389 => 1976882281, + 390 => 480328050, + 391 => 787344748, + 392 => 563015239, + 393 => 16754472, + 394 => 981119784, + 395 => 1406637473, + 396 => 536713968, + 397 => 360891376, + 398 => 1220379656, + 399 => 1066135667, + 400 => 1818796232, + 401 => 1698238530, + 402 => 811962567, + 403 => 1756557520, + 404 => 928711771, + 405 => 787618488, + 406 => 1788036074, + 407 => 276472949, + 408 => 796999760, + 409 => 423305139, + 410 => 87087490, + 411 => 44873146, + 412 => 1191147945, + 413 => 1360525302, + 414 => 969043932, + 415 => 1027824437, + 416 => 1557571987, + 417 => 456217282, + 418 => 812716318, + 419 => 570110394, + 420 => 1805308972, + 421 => 405571985, + 422 => 1007845623, + 423 => 1910852947, + 424 => 1208267561, + 425 => 1537905911, + 426 => 1419914777, + 427 => 147259538, + 428 => 992656858, + 429 => 527504405, + 430 => 1339250140, + 431 => 1976448129, + 432 => 476485024, + 433 => 440030109, + 434 => 1573811563, + 435 => 1000473005, + 436 => 819656038, + 437 => 1638682620, + 438 => 418403996, + 439 => 1143247854, + 440 => 582317622, + 441 => 1183310992, + 442 => 535206720, + 443 => 504939205, + 444 => 326716144, + 445 => 592661009, + 446 => 1656512419, + 447 => 36176672, + 448 => 548492516, + 449 => 907176660, + 450 => 273897385, + 451 => 100927512, + 452 => 1428435597, + 453 => 127130221, + 454 => 886491876, + 455 => 685012689, + 456 => 1434020358, + 457 => 951467657, + 458 => 1416938749, + 459 => 362026632, + 460 => 655793567, + 461 => 647095931, + 462 => 432125764, + 463 => 965086113, + 464 => 476799618, + 465 => 1015934308, + 466 => 257635467, + 467 => 1512302878, + 468 => 79769223, + 469 => 1504612987, + 470 => 73297012, + 471 => 1274852655, + 472 => 494987556, + 473 => 2089361630, + 474 => 490385854, + 475 => 1422016429, + 476 => 1341985334, + 477 => 1885093155, + 478 => 1916760553, + 479 => 889778335, + 480 => 1674453167, + 481 => 1713852635, + 482 => 1549304812, + 483 => 296305177, + 484 => 666669456, + 485 => 560764435, + 486 => 779715710, + 487 => 487043007, + 488 => 421082425, + 489 => 1143431972, + 490 => 2008953340, + 491 => 1491890307, + 492 => 1206314579, + 493 => 523936740, + 494 => 1755120219, + 495 => 418972796, + 496 => 749287058, + 497 => 1696817863, + 498 => 1717373309, + 499 => 870547325, + 500 => 223562634, + 501 => 934329190, + 502 => 1529266406, + 503 => 1345148881, + 504 => 1970205647, + 505 => 1457748715, + 506 => 1725686442, + 507 => 926539411, + 508 => 702470141, + 509 => 633889367, + 510 => 547838485, + 511 => 2141652788, + 512 => 1063009072, + 513 => 423644616, + 514 => 888222761, + 515 => 1198209401, + 516 => 912545471, + 517 => 1016001765, + 518 => 159726197, + 519 => 190602685, + 520 => 1295771559, + 521 => 671131926, + 522 => 1604599209, + 523 => 1285652756, + 524 => 1712781904, + 525 => 105716946, + 526 => 819266132, + 527 => 790237123, + 528 => 1711884110, + 529 => 275376450, + 530 => 1013177147, + 531 => 55819056, + 532 => 1549192924, + 533 => 1572206218, + 534 => 406331161, + 535 => 565204128, + 536 => 933287178, + 537 => 1527890750, + 538 => 1768384292, + 539 => 1454779972, + 540 => 1774406956, + 541 => 1762318695, + 542 => 407002865, + 543 => 1698671769, + 544 => 43169075, + 545 => 1300859401, + 546 => 1510736243, + 547 => 1082338406, + 548 => 745756907, + 549 => 924918430, + 550 => 900877598, + 551 => 216555438, + 552 => 1649458365, + 553 => 1044805333, + 554 => 2067764910, + 555 => 859841245, + 556 => 1916769405, + 557 => 1260940982, + 558 => 289786305, + 559 => 953824006, + 560 => 1713272584, + 561 => 502346743, + 562 => 1464778420, + 563 => 1361959183, + 564 => 1138279916, + 565 => 492272852, + 566 => 1859681450, + 567 => 539987142, + 568 => 1617587955, + 569 => 2101464278, + 570 => 200151039, + 571 => 959071933, + 572 => 707465804, + 573 => 173705211, + 574 => 885542153, + 575 => 257263103, + 576 => 2071479, + 577 => 993808693, + 578 => 1283257970, + 579 => 1671785630, + 580 => 1465789747, + 581 => 855760111, + 582 => 786581947, + 583 => 1341065172, + 584 => 851474811, + 585 => 1714647430, + 586 => 1020825986, + 587 => 1062037601, + 588 => 1247859599, + 589 => 80273748, + 590 => 294499740, + 591 => 1544483828, + 592 => 2146225591, + 593 => 1488941726, + 594 => 1089476888, + 595 => 677448503, + 596 => 1058852678, + 597 => 1796534318, + 598 => 401310483, + 599 => 86754967, + 600 => 635844167, + 601 => 1352060911, + 602 => 1714798042, + 603 => 46701878, + 604 => 633031562, + 605 => 1592934204, + 606 => 1497057224, + 607 => 852478008, + 608 => 586175477, + 609 => 1115793062, + 610 => 1959639926, + 611 => 996865597, + 612 => 641108113, + 613 => 1447650639, + 614 => 1910959303, + 615 => 1826117748, + 616 => 2033070643, + 617 => 678711733, + 618 => 362737528, + 619 => 678229871, + 620 => 771572421, + 621 => 359403739, + 622 => 1464964600, + 623 => 1470048875, + 624 => 1978674187, + 625 => 1757139457, + 626 => 311222661, + 627 => 392567063, + 628 => 214478610, + 629 => 74054650, + 630 => 883910229, + 631 => 1095085456, + 632 => 2094065791, + 633 => 1671376809, + 634 => 89134610, + 635 => 1324053753, + 636 => 401395386, + 637 => 2019041153, + 638 => 1307319310, + 639 => 489542236, + 640 => 187300752, + 641 => 1681281033, + 642 => 679223641, + 643 => 883424681, + 644 => 1310256595, + 645 => 1490989062, + 646 => 432062367, + 647 => 538587517, + 648 => 1485839025, + 649 => 1089477132, + 650 => 525332428, + 651 => 603356507, + 652 => 1461087095, + 653 => 469337957, + 654 => 1043543322, + 655 => 1983767278, + 656 => 559408349, + 657 => 1671176017, + 658 => 607180208, + 659 => 556751034, + 660 => 1944442549, + 661 => 487747092, + 662 => 592367658, + 663 => 1703823397, + 664 => 1806351666, + 665 => 380191236, + 666 => 421818129, + 667 => 631648909, + 668 => 709922505, + 669 => 1754855157, + 670 => 2032872198, + 671 => 958208614, + 672 => 1086781016, + 673 => 1825028839, + 674 => 866328947, + 675 => 2017738402, + 676 => 58114218, + 677 => 423327193, + 678 => 1335248822, + 679 => 1988402350, + 680 => 745925233, + 681 => 861487395, + 682 => 594421820, + 683 => 1005210410, + 684 => 137556584, + 685 => 482813092, + 686 => 718098163, + 687 => 1532452336, + 688 => 145405987, + 689 => 1375811318, + 690 => 8212504, + 691 => 1961006752, + 692 => 87977687, + 693 => 1063955562, + 694 => 749374878, + 695 => 512086922, + 696 => 197470372, + 697 => 1460865993, + 698 => 1117369516, + 699 => 1391518040, + 700 => 463319189, + 701 => 1650519211, + 702 => 2129587681, + 703 => 1326557664, + 704 => 573780059, + 705 => 1518476136, + 706 => 1460649775, + 707 => 1439417296, + 708 => 1130104929, + 709 => 1038500228, + 710 => 944727597, + 711 => 1962818890, + 712 => 1420679078, + 713 => 59794210, + 714 => 289448956, + 715 => 1940006682, + 716 => 1691892854, + 717 => 957678549, + 718 => 296304861, + 719 => 1169402574, + 720 => 1359192441, + 721 => 41924820, + 722 => 458842859, + 723 => 1853005894, + 724 => 50198106, + 725 => 1363176370, + 726 => 1346330455, + 727 => 1073280677, + 728 => 1379036103, + 729 => 825204617, + 730 => 1378906416, + 731 => 8863397, + 732 => 1856759244, + 733 => 1579665708, + 734 => 724134508, + 735 => 540471081, + 736 => 882526400, + 737 => 2087089722, + 738 => 1310649395, + 739 => 198087500, + 740 => 2020445362, + 741 => 999061984, + 742 => 326583443, + 743 => 1357207463, + 744 => 395261561, + 745 => 830749831, + 746 => 331653708, + 747 => 339037024, + 748 => 1530778584, + 749 => 1027989307, + 750 => 1992828664, + 751 => 1155670303, + 752 => 907713798, + 753 => 2044119265, + 754 => 1170759256, + 755 => 1469372962, + 756 => 692325035, + 757 => 983076762, + 758 => 345110685, + 759 => 993629329, + 760 => 1510007484, + 761 => 384995557, + 762 => 1568196499, + 763 => 2115080537, + 764 => 2062453036, + 765 => 2144818650, + 766 => 795622433, + 767 => 1403926606, + 768 => 1539098068, + 769 => 1741836791, + 770 => 2117550343, + 771 => 698625728, + 772 => 237871535, + 773 => 132395393, + 774 => 1628283410, + 775 => 299143983, + 776 => 338344902, + 777 => 435227585, + 778 => 1753281361, + 779 => 85914561, + 780 => 1189934743, + 781 => 1513064930, + 782 => 1249213196, + 783 => 425477913, + 784 => 2010357330, + 785 => 546427725, + 786 => 932754690, + 787 => 1828864949, + 788 => 1050392631, + 789 => 1411655550, + 790 => 1430504279, + 791 => 1731407378, + 792 => 1353245417, + 793 => 677189912, + 794 => 279612571, + 795 => 1734035551, + 796 => 759874137, + 797 => 1901141908, + 798 => 1363917081, + 799 => 1472165863, + 800 => 1973442683, + 801 => 1711199029, + 802 => 195993777, + 803 => 1879385522, + 804 => 152647702, + 805 => 681984954, + 806 => 888438966, + 807 => 1823952394, + 808 => 463085882, + 809 => 1728456678, + 810 => 1116044312, + 811 => 1226881086, + 812 => 1199399740, + 813 => 228149441, + 814 => 1017263351, + 815 => 1621300217, + 816 => 463581853, + 817 => 1519659580, + 818 => 514191093, + 819 => 386045670, + 820 => 465441848, + 821 => 1827440682, + 822 => 1408084362, + 823 => 1770834172, + 824 => 1817616091, + 825 => 1958865212, + 826 => 1998157067, + 827 => 1837756522, + 828 => 1718643011, + 829 => 461697790, + 830 => 1461847621, + 831 => 725172472, + 832 => 445080939, + 833 => 84687327, + 834 => 1592702134, + 835 => 504830135, + 836 => 1496591207, + 837 => 268160472, + 838 => 819822239, + 839 => 595788466, + 840 => 1825616918, + 841 => 942145680, + 842 => 1134110122, + 843 => 1846687232, + 844 => 1917722379, + 845 => 693468426, + 846 => 1762137835, + 847 => 2120741278, + 848 => 490868845, + 849 => 2072931276, + 850 => 1762276550, + 851 => 1493060495, + 852 => 297558393, + 853 => 1439417678, + 854 => 1036091058, + 855 => 77589692, + 856 => 319568233, + 857 => 1686755208, + 858 => 962704149, + 859 => 1135705459, + 860 => 1430130631, + 861 => 1445133897, + 862 => 1694434228, + 863 => 915616028, + 864 => 1421678767, + 865 => 85850656, + 866 => 1527961296, + 867 => 1385894981, + 868 => 1906801542, + 869 => 1221224053, + 870 => 304245372, + 871 => 1513831255, + 872 => 316904424, + 873 => 1511276989, + 874 => 699931152, + 875 => 485040484, + 876 => 68448515, + 877 => 2114589254, + 878 => 1476959576, + 879 => 253634195, + 880 => 1642245265, + 881 => 441241465, + 882 => 751639499, + 883 => 2046819575, + 884 => 1322866260, + 885 => 2006999280, + 886 => 2058362776, + 887 => 727563038, + 888 => 625030727, + 889 => 1997804711, + 890 => 1474630772, + 891 => 222975352, + 892 => 90684435, + 893 => 270379420, + 894 => 134225531, + 895 => 947556218, + 896 => 1748907887, + 897 => 1338312882, + 898 => 937630784, + 899 => 1305242989, + 900 => 841960554, + 901 => 365110020, + 902 => 710060485, + 903 => 714855544, + 904 => 982814857, + 905 => 320147840, + 906 => 1793905074, + 907 => 2057727238, + 908 => 1002378542, + 909 => 138749803, + 910 => 904704780, + 911 => 251383728, + 912 => 1225894379, + 913 => 989303396, + 914 => 1587110591, + 915 => 799390430, + 916 => 118290709, + 917 => 2044387857, + 918 => 1340417728, + 919 => 1245514485, + 920 => 1333716899, + 921 => 287877337, + 922 => 2384857, + 923 => 123781151, + 924 => 1294703936, + 925 => 1406983191, + 926 => 86297517, + 927 => 1526158758, + 928 => 1257889330, + 929 => 869169158, + 930 => 962887486, + 931 => 1417883403, + 932 => 759629960, + 933 => 1813857742, + 934 => 2004730172, + 935 => 2122523749, + 936 => 573927740, + 937 => 2051120863, + 938 => 604085823, + 939 => 1575536493, + 940 => 1084277305, + 941 => 631725863, + 942 => 1389005554, + 943 => 1514247048, + 944 => 2084290575, + 945 => 1075299008, + 946 => 77042006, + 947 => 720033681, + 948 => 908814797, + 949 => 1124487867, + 950 => 1263390581, + 951 => 1924621728, + 952 => 1571318674, + 953 => 2012215808, + 954 => 376907161, + 955 => 957512451, + 956 => 1096373688, + 957 => 1559383002, + 958 => 1074352984, + 959 => 1732940805, + 960 => 1917203897, + 961 => 420897174, + 962 => 821804851, + 963 => 1173135881, + 964 => 1423489263, + 965 => 320098543, + 966 => 100527068, + 967 => 402321524, + 968 => 1613239724, + 969 => 823125167, + 970 => 791960391, + 971 => 122669138, + 972 => 2035875986, + 973 => 1456607983, + 974 => 745660472, + 975 => 1906208657, + 976 => 1468649460, + 977 => 738500035, + 978 => 1770889920, + 979 => 552767217, + 980 => 1044220357, + 981 => 256793509, + 982 => 2113501586, + 983 => 862992394, + 984 => 1296680771, + 985 => 723223955, + 986 => 1631281918, + 987 => 174881107, + 988 => 1469988412, + 989 => 1353186255, + 990 => 2002348596, + 991 => 1208428346, + 992 => 2039648774, + 993 => 163134477, + 994 => 2126247457, + 995 => 160603372, + 996 => 270916623, + 997 => 1917511108, + 998 => 2097233868, + 999 => 23515278, +); + +$rng = new \RNG\MT19937(SEED); +foreach ($result as $ret) { + $rng_next = rng_rand($rng); + if ($ret !== $rng_next) { + die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); + } +} + +die('OK, Result is consistent.'); +?> +--EXPECT-- +OK, Result is consistent. diff --git a/ext/standard/tests/rng/mt19937_result_64.phpt b/ext/standard/tests/rng/mt19937_result_64.phpt new file mode 100644 index 0000000000000..9685fcec7f241 --- /dev/null +++ b/ext/standard/tests/rng/mt19937_result_64.phpt @@ -0,0 +1,1027 @@ +--TEST-- +Test class: MT19937: consistent result in 64bit range. +--SKIPIF-- + +--FILE-- +next64(); } var_export($arr);' +$result = array ( + 0 => -1298354032638611995, + 1 => 5836098993699293313, + 2 => 3392703261234277801, + 3 => 3773471124928680318, + 4 => -7974065807368502750, + 5 => -7460883356170798335, + 6 => -654591539783086735, + 7 => -6397753339937154418, + 8 => -4631855007149765541, + 9 => -6390507853669706378, + 10 => -4653840397050535054, + 11 => -713764701953347317, + 12 => 154736802364647050, + 13 => 1963552194952435410, + 14 => 5510110880054540551, + 15 => -6338095008519208729, + 16 => -3508339191409949667, + 17 => -2357938176985657929, + 18 => -652136702356950339, + 19 => -5097105691610658981, + 20 => -6595166134903412700, + 21 => -5212060869759209489, + 22 => 8625679179711580924, + 23 => 6005977249153676933, + 24 => 8110011575351034487, + 25 => -4986356374521057394, + 26 => -110411362861080239, + 27 => -5960627993306379899, + 28 => -3858643550111144651, + 29 => 3152811605224055880, + 30 => 495281634690674914, + 31 => -3682519061263046395, + 32 => -1776005691041470381, + 33 => 455195670278792590, + 34 => 9071136937505938000, + 35 => -8739049689330811610, + 36 => -7445732931968700448, + 37 => 958447497090921477, + 38 => -1935256691803255732, + 39 => -5012604146867671540, + 40 => -3350850779428771266, + 41 => -9219262984178842478, + 42 => -3501387414075530670, + 43 => 1770306876347866926, + 44 => 4038915478038249751, + 45 => 4772524321543247623, + 46 => 8635027014520198207, + 47 => 8473939944480035328, + 48 => -5358598721057174868, + 49 => 3284498216867551630, + 50 => -8643223960532744533, + 51 => 3094297982135069923, + 52 => -4264630531593224957, + 53 => -1325019537204297210, + 54 => -7203570542402818127, + 55 => 2770396547958162300, + 56 => 9032018447984850213, + 57 => 6960785775196755499, + 58 => -2792810943191082794, + 59 => -1639966582550029759, + 60 => 7080759088998192901, + 61 => 5819872255997237992, + 62 => -7961722632864028551, + 63 => 3464631228428906708, + 64 => 2321366769504866425, + 65 => -5762840308337125075, + 66 => -3696603640812287884, + 67 => -7866861898200453685, + 68 => -493819727695128187, + 69 => -6750505253117400458, + 70 => -2058255919707862647, + 71 => 9138789271661798525, + 72 => 6486180062338238785, + 73 => -5271519239924383335, + 74 => -9150892595068865547, + 75 => 4162279061252991309, + 76 => 4518980733272769928, + 77 => -3822152476653792657, + 78 => 9134318808161933146, + 79 => -1566245377009879572, + 80 => -1007711810009430432, + 81 => -8610345554941663163, + 82 => 4657666303540708943, + 83 => -5149186252015253732, + 84 => 6778048861135845124, + 85 => 9198440228778986738, + 86 => 4179571914677089366, + 87 => 6522134891585035509, + 88 => -6440647688815379116, + 89 => 5772593006367276697, + 90 => -4266077988104033019, + 91 => -4024395138091764610, + 92 => -2722564504079640749, + 93 => -924075922164664144, + 94 => 1979758274959812003, + 95 => -1646826503904481997, + 96 => 6199123627645298285, + 97 => -3202715840780070834, + 98 => -1879711524954947011, + 99 => 787958398515564458, + 100 => 3611780175214423832, + 101 => 5432590600945396492, + 102 => -6880637691982512501, + 103 => 1590535616184670436, + 104 => 2636870143694704601, + 105 => -8931424313021756903, + 106 => -5730640997154623263, + 107 => -2644786864245688770, + 108 => -6505028796475084170, + 109 => -7717773127317598990, + 110 => -5328970154833455411, + 111 => 4656269175089175703, + 112 => -1841728806467775604, + 113 => 8158878559794074293, + 114 => 378542463650683894, + 115 => -744123073029574119, + 116 => -6415308673353835845, + 117 => -8979759727090384584, + 118 => -5859490452627479156, + 119 => 9030426278940261143, + 120 => -1356016984039502986, + 121 => -8930441935939769523, + 122 => 1331114927639073653, + 123 => -7978063769630020688, + 124 => -7097510558660725174, + 125 => -1078280472920444094, + 126 => 7662101443215512126, + 127 => 4878056538246497663, + 128 => 1796586818700619001, + 129 => 8962244049475283635, + 130 => 8571516933595884559, + 131 => 548962472926869090, + 132 => -5639585442283654895, + 133 => -5221404194928332658, + 134 => -4984099484011911936, + 135 => 7643427270541295655, + 136 => 278524452907077118, + 137 => -1679111960602691092, + 138 => -3885276786282854226, + 139 => 3047386825968502474, + 140 => 5769882576438862440, + 141 => -7176792422584779956, + 142 => 6723659075086080406, + 143 => 2878403836392144284, + 144 => 3270678069058900432, + 145 => -2437005409996287556, + 146 => 5351302168608791167, + 147 => -7652085313150896467, + 148 => 8374727214459615129, + 149 => 7584897735062938491, + 150 => -2165012449405930837, + 151 => -5668536604008667678, + 152 => 5151684114263176453, + 153 => 1188712465327085540, + 154 => 3663958973691065032, + 155 => -1260230926584429461, + 156 => -2685595763286502687, + 157 => -834996760020847043, + 158 => 963904124300871488, + 159 => -7757378282541740312, + 160 => 8863591702688786162, + 161 => 400459910998276272, + 162 => 6892080971791219349, + 163 => 7638645436986862801, + 164 => -7306621909572786035, + 165 => -6055167339241504174, + 166 => -2972403175669949939, + 167 => -4067023586511689649, + 168 => 7391629584192145636, + 169 => -3790266658564140107, + 170 => -1971508492323999700, + 171 => 4842080115564572286, + 172 => -199280079276369937, + 173 => -2706006318568906179, + 174 => -4953372257765276574, + 175 => 6559028147399988675, + 176 => -2152928903706413560, + 177 => -2435724825273950163, + 178 => -815965107342160504, + 179 => 1978436855060560, + 180 => 305128482875869981, + 181 => 5793570005859834630, + 182 => -86401330550030585, + 183 => 2745691277683745058, + 184 => 3087562892541503441, + 185 => -4453559782371503653, + 186 => 1282595912348106348, + 187 => -5433056083407159958, + 188 => 8654571904944265830, + 189 => 187939471944096899, + 190 => -4153766511781204685, + 191 => -3796321442965086290, + 192 => 2759069321418590426, + 193 => 437254804636289566, + 194 => -4389148773726967597, + 195 => 4125986538072562393, + 196 => 4836264077342756432, + 197 => 8427754774290443075, + 198 => 4610337880454563808, + 199 => -7963762649129819930, + 200 => -2823403396962049916, + 201 => 6974705345195532705, + 202 => 7977573369285719408, + 203 => -3087631145065166613, + 204 => 6846175813381275494, + 205 => 748075847266167668, + 206 => -8214861129748320275, + 207 => 8324023999005111915, + 208 => -5067302577840675451, + 209 => 6981180018906260340, + 210 => -2939258085067648222, + 211 => 8657327988520164007, + 212 => -8067804747713402386, + 213 => -6249769008475799259, + 214 => 8526857487870208042, + 215 => -6942672964829812477, + 216 => 4092975191107610427, + 217 => -4927805681110351013, + 218 => 7040791761930199032, + 219 => 3594062965252892636, + 220 => 5002070287115602208, + 221 => 4597390719008736650, + 222 => 2806470308295775266, + 223 => -4217410739296532928, + 224 => 4711514842750834089, + 225 => 2352760622271696945, + 226 => -6176575726340819749, + 227 => 7614907236844367266, + 228 => -6128602992990192366, + 229 => -6275332898205192944, + 230 => 5633223851973528822, + 231 => 3711932054503167811, + 232 => 4095677534142454473, + 233 => 2213071813133980220, + 234 => 685212415328855287, + 235 => 629616541418744415, + 236 => 4251910738367627708, + 237 => 4212382417841061723, + 238 => -6919177827456091577, + 239 => -1981896293134245569, + 240 => -4063300884089626186, + 241 => -5138317070671117262, + 242 => 5726647022645750822, + 243 => 6697706950228926334, + 244 => 3617070490877609544, + 245 => -1189966281745833721, + 246 => -8084580741675661368, + 247 => -3370376190564890376, + 248 => 6436326826540713358, + 249 => -3694619677611852037, + 250 => 1920388405143893708, + 251 => -5310445665441370205, + 252 => -1522806425980045865, + 253 => -3623210408775271130, + 254 => 6034172565290796206, + 255 => 4705896757413678697, + 256 => 9131178400029907857, + 257 => 7629775426807034611, + 258 => 7838705910147836363, + 259 => 1372037585240111995, + 260 => -7316151130088451540, + 261 => -4663341819453308375, + 262 => -3734059547776894555, + 263 => 7037442493196279686, + 264 => -3741771534879698300, + 265 => 8703125422950807136, + 266 => -5139278178720944876, + 267 => 3490358096811829569, + 268 => 8016875821923010172, + 269 => -3256438668999762807, + 270 => -3204704378555092273, + 271 => 3496127992503949618, + 272 => 370819537543828499, + 273 => -5469618558411056947, + 274 => 6406003054512063805, + 275 => 7738479646946148188, + 276 => -4278004604042678869, + 277 => -684778739162135109, + 278 => -1981820249995944596, + 279 => 2489245407515010572, + 280 => -3729844633583065106, + 281 => -5864393251412528609, + 282 => -8668994046897751639, + 283 => -2472202050878891636, + 284 => -4551769339249583699, + 285 => 1719284339743952251, + 286 => 6077084982784102390, + 287 => 7606749177538350079, + 288 => 17793875401286251, + 289 => -7423642039108314820, + 290 => -5855706019643803170, + 291 => 6756687478660140968, + 292 => 7314112936654856973, + 293 => 8768828455972950210, + 294 => -7727711738139655511, + 295 => 2529733511344941033, + 296 => -10806620070156995, + 297 => -9088208860643977618, + 298 => 9095475254472073309, + 299 => 3447230800227437871, + 300 => 5461859807938846687, + 301 => -3716741050051511700, + 302 => 5437699719732428408, + 303 => -5587120437363502992, + 304 => 5035209009095986509, + 305 => -1613565283504100230, + 306 => 5507076759965846175, + 307 => -2031728649313406743, + 308 => -982800223771778197, + 309 => 3115891640940228319, + 310 => 6627756634394862007, + 311 => -5862793972879043370, + 312 => -1450062220691528702, + 313 => 2673382306618290735, + 314 => 1842357231431186421, + 315 => 7592731058794879777, + 316 => -458855890037088429, + 317 => 765660472431536626, + 318 => 3447960115308674819, + 319 => -7216956708971895623, + 320 => 1608901216369942546, + 321 => 5834486655591906131, + 322 => -7191725620940939251, + 323 => 3711387473271874298, + 324 => -5683484028244577256, + 325 => 4512571201078229687, + 326 => -5896101489210618166, + 327 => 8963968883865929180, + 328 => 4805281131471060642, + 329 => 5215638273390457205, + 330 => -1744109758922302424, + 331 => 5088399440043872330, + 332 => -2930301407563971575, + 333 => 3623390139093116187, + 334 => 6098187891143470570, + 335 => -984504852782893875, + 336 => -9111366226792188465, + 337 => 7441708998216678724, + 338 => 499197336626850738, + 339 => -6977044020412728996, + 340 => 6407448968010302022, + 341 => 5106044555868018261, + 342 => 1181602064519547209, + 343 => 6168416258165226464, + 344 => 1249027924661792236, + 345 => 70544880413519169, + 346 => 755722583308327124, + 347 => 6437081187932153620, + 348 => 1696257586554607506, + 349 => -8848613013391818064, + 350 => 3979881536324491606, + 351 => -153725183337475136, + 352 => 4928733180040853200, + 353 => -5899858037466232928, + 354 => -8739216649425747192, + 355 => 8115148273707940500, + 356 => -6243203713052129723, + 357 => 2486347603642699316, + 358 => -3913495114967021654, + 359 => 2545239381915424156, + 360 => -6771369907494882903, + 361 => 3941430150522290317, + 362 => 431198449908635493, + 363 => -6881853519600423605, + 364 => -6600914142987600109, + 365 => -6602028147467715254, + 366 => -2497303611498851751, + 367 => 6220268064906010195, + 368 => 7580844060182375540, + 369 => -7188351497219004776, + 370 => -1091250565421665344, + 371 => 2805330421209542479, + 372 => 3395270957383317775, + 373 => 2848883659592341185, + 374 => -5297456160259195274, + 375 => -1328476194575465921, + 376 => 7797202157164138947, + 377 => -8389998634457254843, + 378 => 5947026769020264245, + 379 => 2964478217432541475, + 380 => -5475878551949073974, + 381 => -4976038711371029838, + 382 => -730407386813125707, + 383 => 6834344662205755549, + 384 => -5225992335432309778, + 385 => -257125126380167808, + 386 => 2043300927213429507, + 387 => -4459896079677577634, + 388 => 2906360582882072450, + 389 => -3386171856880015486, + 390 => -8225282455270124604, + 391 => -7716084423460352461, + 392 => -1177906097073969510, + 393 => 8012301785433933675, + 394 => 9022803999032102653, + 395 => -6158805875765650395, + 396 => -6822454449106439632, + 397 => 2401853699459027135, + 398 => 6527269143079698217, + 399 => -6730785556063653938, + 400 => -1495000497961195925, + 401 => 1683573732922772324, + 402 => 1311233777163077492, + 403 => 7631632610572016661, + 404 => 3977877440315543501, + 405 => -8859996429402148739, + 406 => -8143978756991446653, + 407 => 8738225651171338227, + 408 => 3982137802642445433, + 409 => 4416867861726047692, + 410 => 3998115038649454677, + 411 => -6351391500569832968, + 412 => -2833540730440134023, + 413 => -1282705559961476907, + 414 => -3683713021298219523, + 415 => -5889568620103433743, + 416 => 3823216154325316542, + 417 => -4765536912806104721, + 418 => -5591123494080898128, + 419 => 7042219411268568421, + 420 => -2764814156156632799, + 421 => -8704812297616069631, + 422 => -1973634271097980396, + 423 => -3310095324729580740, + 424 => 4216531275946448793, + 425 => -3308903768913045729, + 426 => 2556007140344433309, + 427 => 8899954424026225017, + 428 => 2745070222524526352, + 429 => 8269565677923400423, + 430 => -6162015492513596269, + 431 => -3891664882912304583, + 432 => -6234616454172642240, + 433 => -5321656474895243125, + 434 => -2067443541267395350, + 435 => 2613447852721338030, + 436 => 2722188281392956282, + 437 => 6012362815553290953, + 438 => 587968275293676685, + 439 => -5759757920334230233, + 440 => -4339964662455361805, + 441 => 6456534141562255854, + 442 => -7083409418036919839, + 443 => -765542455511910851, + 444 => 5368973071210785102, + 445 => -5779762190138168592, + 446 => 778973365703234360, + 447 => 1152988533761580789, + 448 => -3423739709975031452, + 449 => 8054187112911133403, + 450 => 7232386088634304008, + 451 => 6099373128238475504, + 452 => 8442315342611096321, + 453 => -3037216819677177331, + 454 => 8610366116776791767, + 455 => 7771354890067484512, + 456 => -7916391535125519160, + 457 => -4813567905150306883, + 458 => 1016109457240081442, + 459 => -6932643457446308374, + 460 => -6990203142183759437, + 461 => 20485765888835646, + 462 => -7325321944650631122, + 463 => 741290029534325580, + 464 => -7641557003296509940, + 465 => 8271140531326049814, + 466 => 6525171678446259100, + 467 => -1226243017375594294, + 468 => 4930001751236623806, + 469 => 5189057710675562203, + 470 => -9132872942906065329, + 471 => -6515277209601366256, + 472 => -542824357291915904, + 473 => 661785793816538914, + 474 => 7806659669015700854, + 475 => -7594301610626462911, + 476 => -4949219436836948991, + 477 => 3237607862161438214, + 478 => -9028965802280970316, + 479 => -9218122208963647477, + 480 => -1978087993815284947, + 481 => 7059249924119544850, + 482 => -6219064407190101537, + 483 => 863520939650179304, + 484 => -4589120361687168674, + 485 => 6802887958390083749, + 486 => -958702513632827937, + 487 => 6405174686132264739, + 488 => -5831141267961463930, + 489 => -3234915490171904541, + 490 => 8969784566778476363, + 491 => -291903683860336619, + 492 => -7308341062668973273, + 493 => -4434139096627481945, + 494 => -5819639760925231202, + 495 => -1246700596974694796, + 496 => -926294514070292453, + 497 => -182417491352012328, + 498 => 2327156079585512328, + 499 => -431642319120391907, + 500 => 4226253332420415716, + 501 => 3432135224167894613, + 502 => -9053451211515940047, + 503 => -8660789102663595156, + 504 => 5213773757658558849, + 505 => 5721470484654807480, + 506 => 5716357735476852954, + 507 => 4914007671303813281, + 508 => -7499871566740484247, + 509 => 4005422196609743888, + 510 => 7422654629456619790, + 511 => 5323015293454485721, + 512 => 3206797011493482038, + 513 => 4163679694653236151, + 514 => -209528889153889728, + 515 => 8006834208609437950, + 516 => -3169348507731268351, + 517 => -7885746341771093857, + 518 => -6421306488165958557, + 519 => -4985450993192220349, + 520 => 7217909293569389752, + 521 => 7247033194845905848, + 522 => -2590822493528118400, + 523 => -3504519655762209803, + 524 => -3015233104408826313, + 525 => 3467765228043788357, + 526 => 6633389193095526437, + 527 => 8891035241982068531, + 528 => -625849196951478227, + 529 => -8055449978018730212, + 530 => -3181973617418353987, + 531 => 1403937661980399111, + 532 => -8243149886504182713, + 533 => -8339026628722614025, + 534 => -1744257813675245993, + 535 => 6815863021825623249, + 536 => -1823227488350702482, + 537 => 2594184571987531057, + 538 => 1829432382283380735, + 539 => -494681499403531782, + 540 => -1069080623535206114, + 541 => -7545696786544732734, + 542 => 958453462232008483, + 543 => 925135452714226313, + 544 => 5987853204506605232, + 545 => 6931359661286250539, + 546 => -4350677104183539217, + 547 => -2596086968000715775, + 548 => -8380203162563515613, + 549 => 5974070071764339034, + 550 => 7485963024966894317, + 551 => 2023013354072520527, + 552 => 2532577814444057273, + 553 => -4696744620723997587, + 554 => -2279730966827752471, + 555 => 4777510222850776967, + 556 => -5799625610128859789, + 557 => 6624437544552774777, + 558 => 110996273954605107, + 559 => -4405435640494169605, + 560 => 7637365026700900170, + 561 => 6159219884810196150, + 562 => 5128989505659853244, + 563 => -7516787031653864745, + 564 => 5997048393883803686, + 565 => -1165735675048191965, + 566 => 1770573307792507038, + 567 => -2152813512726316937, + 568 => -7968666273089304190, + 569 => 1142286482949663692, + 570 => -2306052175543930643, + 571 => 4147801442238039632, + 572 => -3700725306810280670, + 573 => -3654761423580211775, + 574 => 534116591750101426, + 575 => -6878809272645857983, + 576 => -7293118472324213901, + 577 => 1442674233198961155, + 578 => -4188267440491322022, + 579 => 2643725095778940725, + 580 => 8553471236938857707, + 581 => 1791375837589172121, + 582 => -7934789200660844641, + 583 => 7448185700812831993, + 584 => -7626276709513080360, + 585 => -4635549146494647448, + 586 => -2036265356195773324, + 587 => 6998513026958591645, + 588 => 5394496858021440185, + 589 => -9051997413327359563, + 590 => -8618067955393091081, + 591 => 1944685601971007433, + 592 => 847462013631544026, + 593 => -6972995659873629382, + 594 => -3275313172533142906, + 595 => 1015743613198235257, + 596 => -3726732214241596155, + 597 => 4505523512778000656, + 598 => -3624088937191829578, + 599 => 5500359135442881393, + 600 => 8619627912972281301, + 601 => -1239258588820677738, + 602 => -1664693509665310555, + 603 => 2396743401664685216, + 604 => -8679235498747088157, + 605 => -7025151463495202113, + 606 => -6924626970252278689, + 607 => -6515227054268789472, + 608 => 6125729733533694965, + 609 => 2107030272592464378, + 610 => -7911725719775211224, + 611 => 5570759595421690039, + 612 => 3569548336753860541, + 613 => -8029762795433776209, + 614 => -7185326798872019861, + 615 => 836186908667673461, + 616 => -269771810547353474, + 617 => 1913426120502000335, + 618 => 7487484489747998491, + 619 => -6169345947734947898, + 620 => 3634230765129958076, + 621 => 4460062308506470947, + 622 => -6951241313282668555, + 623 => -3712622117534278665, + 624 => -8399976431522098821, + 625 => 3644843592918599388, + 626 => -3982251042558304021, + 627 => -3424936434689663469, + 628 => -5333156399864152748, + 629 => -1032229273878341508, + 630 => -2675744592881910139, + 631 => -671898552489622434, + 632 => 8571080331913515013, + 633 => 8946583088011533569, + 634 => -7628305275784492063, + 635 => -1070116343844837426, + 636 => 6867413699979618179, + 637 => -7411122471327938208, + 638 => -7127595062469485472, + 639 => -8115384595794422681, + 640 => 2186268474755897419, + 641 => 7432415476353419818, + 642 => 4085932814061005653, + 643 => -3905568684092134131, + 644 => -4353659533339152689, + 645 => 3216706487954116132, + 646 => -5093998474846854795, + 647 => -1391582977849549661, + 648 => 8779450224925116936, + 649 => -1605994067058658692, + 650 => 8069011063083699263, + 651 => 1214912306565431735, + 652 => 6709185224030426434, + 653 => 3494714947770452926, + 654 => 2736253495598964093, + 655 => 3893750144887449922, + 656 => -2221733860098778130, + 657 => -3361990978740614629, + 658 => -6796450427939454443, + 659 => -824892422555546719, + 660 => 2196090383185315343, + 661 => -7336783028317660216, + 662 => 6113705576716580252, + 663 => -3292178199597353218, + 664 => -6275790122370780025, + 665 => 7795060189592870843, + 666 => -5237345866487717212, + 667 => 3971378925938244568, + 668 => 310511762720174763, + 669 => 5178566173762408616, + 670 => -7346949169146542186, + 671 => 8495757122964278799, + 672 => -5337255259936637926, + 673 => 3037733426273005184, + 674 => -1102449995278023704, + 675 => -821832531487791235, + 676 => -355453583603335536, + 677 => 1085220522087750357, + 678 => -4789325384060347950, + 679 => -7366668779145444980, + 680 => 1640899317892579901, + 681 => -196622906433231919, + 682 => -8322390630144645323, + 683 => -6005007200754143497, + 684 => -5074829020746811174, + 685 => -7959872358947582320, + 686 => -8716310455813060668, + 687 => 2780900918973730265, + 688 => 4432466677120026430, + 689 => 7426314140033950121, + 690 => 1251377276326690870, + 691 => -4457011914420959063, + 692 => 6321553483289540505, + 693 => -189284966388869317, + 694 => -2055683178109552429, + 695 => -1133714120299781790, + 696 => -4812740959588225086, + 697 => 497081426198945048, + 698 => 7053959145109496304, + 699 => 194177648801788177, + 700 => 1203319287616851715, + 701 => -5877267356421451651, + 702 => -246089255833701575, + 703 => -6156589260176310872, + 704 => 7657299012824609996, + 705 => 759280966141940849, + 706 => -1950063216062768347, + 707 => -5408825696242340486, + 708 => 8834133303405207394, + 709 => 3977348485336283979, + 710 => 1508317718870078411, + 711 => -6028355218356815399, + 712 => -96307019843728889, + 713 => -7498005234917979847, + 714 => -2948113434728289276, + 715 => 2821947051788881355, + 716 => -2284784641138358937, + 717 => -8396301253025908926, + 718 => -301746739587499856, + 719 => -4875434974310467948, + 720 => 1717081962620092095, + 721 => 5390581630300434712, + 722 => 5036849614102582208, + 723 => 1312788705614901494, + 724 => -5902535760706948288, + 725 => 4145408816407429086, + 726 => -8273369689407542529, + 727 => -4247504148622565610, + 728 => 3905508127712723295, + 729 => 5400995242359565655, + 730 => 6574738565688523867, + 731 => -804877697267484089, + 732 => -6267394527622144985, + 733 => -912884997929385534, + 734 => 1786891692964368860, + 735 => 4879652307292919330, + 736 => 5020060065260740150, + 737 => -3042104642060813779, + 738 => -3452264078002814917, + 739 => 5418623320032585862, + 740 => -6461711205384347745, + 741 => 7765980325798131650, + 742 => 1377080371099107696, + 743 => -4818163120178283337, + 744 => -7648572614337752949, + 745 => 6358050281888768959, + 746 => 4759318588921701176, + 747 => 5383092559346434924, + 748 => -4247724047889921915, + 749 => 7827238308909905925, + 750 => 5323210827028510809, + 751 => 4873290316302087875, + 752 => 5108252786882586519, + 753 => -2908018341348975358, + 754 => 3128979040632118883, + 755 => 4650177494953897610, + 756 => -7528573738490143686, + 757 => -454532917121241274, + 758 => 76206372321169060, + 759 => 4427515967358468331, + 760 => -5044887452325991064, + 761 => 4625051155082122176, + 762 => -1509715987152042346, + 763 => -9072995904907086207, + 764 => -9176663506919676151, + 765 => -5307057017128186184, + 766 => -6645106980515465240, + 767 => 5244458042518019000, + 768 => 180470411466752910, + 769 => -7475735498054393622, + 770 => -2932755929924686309, + 771 => 8976005851143810518, + 772 => -4043615981801487507, + 773 => 7609924944450376538, + 774 => 7006175996044522332, + 775 => -1873349750010439219, + 776 => -1905066750569003880, + 777 => -5156847339154749125, + 778 => 5254587227293151191, + 779 => 6270032818236809024, + 780 => 5260476949855499383, + 781 => -4065463299933196800, + 782 => 84354565623605763, + 783 => 1562209966349853341, + 784 => 8141604492556661497, + 785 => 4631374618485187663, + 786 => -1736344223779216019, + 787 => -2197326770774831313, + 788 => -5229275972873263151, + 789 => 4402800826240676548, + 790 => -1378139100744463677, + 791 => -560440813849750900, + 792 => -7780116978836695506, + 793 => 4962683724710060832, + 794 => 5550799649416556300, + 795 => -6911399791169399042, + 796 => -4061160008435427738, + 797 => 7767986280116902618, + 798 => -6327607332220513415, + 799 => 7814408278060204006, + 800 => 6488197001376391378, + 801 => -6924384915482591309, + 802 => -3477241868459142614, + 803 => 9107491680003162069, + 804 => 980456891018555793, + 805 => 8912255135604404421, + 806 => -9137887816350806099, + 807 => 8059710994414227496, + 808 => 6936265680368089049, + 809 => -4097427070116601925, + 810 => 1846107798437843309, + 811 => 303991876291152673, + 812 => -4014454182879547796, + 813 => -2708743804150289875, + 814 => 4126569063962323117, + 815 => -6882063929039426937, + 816 => 1192956279739966268, + 817 => 4407310915518636566, + 818 => 8481315617694569723, + 819 => -6222408302398288806, + 820 => 4015886037078550437, + 821 => 8668992204632718174, + 822 => -400460623494916111, + 823 => -8982573032552951989, + 824 => 8672392152272863731, + 825 => -6158611106603362555, + 826 => -8831923424312527212, + 827 => 4745777402059664803, + 828 => -3243529581453052992, + 829 => 2375666372984608944, + 830 => 3171802886905371406, + 831 => 3226555531453400753, + 832 => 7045559647732554081, + 833 => 1874064673696647081, + 834 => 7190478310326444036, + 835 => -3506460018416637627, + 836 => 6525568861281120853, + 837 => -2277844392017716335, + 838 => -759408331225391077, + 839 => -2974935420362143262, + 840 => 2122212695845544493, + 841 => -8072080039441853758, + 842 => 2000328268837054390, + 843 => -2289823516665995506, + 844 => 6456504585805602526, + 845 => -1886823662558486558, + 846 => 2290668569502564625, + 847 => -6680270166286945474, + 848 => -2351495868823170763, + 849 => 19656174082597500, + 850 => 5621089012976952414, + 851 => 531721331559439320, + 852 => -8306024656968054396, + 853 => 3231710671158139570, + 854 => -7562694142985621983, + 855 => 94458657530853252, + 856 => 5202401925693584748, + 857 => -4430946246341263396, + 858 => -2362197650096845438, + 859 => -9123368000514961544, + 860 => 8923514052293704273, + 861 => 880983619604951169, + 862 => -4596837920095355083, + 863 => -3111332798211493191, + 864 => -2471239256989082213, + 865 => -3195308506029059884, + 866 => 9215628726257374483, + 867 => 161704695809353319, + 868 => 6293919764797836573, + 869 => -4793887103447387348, + 870 => -1645668380029497255, + 871 => 5422568789965030410, + 872 => 3444141560165071933, + 873 => -2135820117029461126, + 874 => 7084800212012529111, + 875 => -7066833691557298423, + 876 => -7434487560691191093, + 877 => 5963843624415108696, + 878 => -6640153064232592304, + 879 => 8275036262341031359, + 880 => -5562431815530562054, + 881 => 2987223643365600456, + 882 => 3603721002299405849, + 883 => 8905940447518713266, + 884 => -9222216201508278235, + 885 => -4277904420357254828, + 886 => 3557641629025736238, + 887 => -144449870201775124, + 888 => 6000718247658497963, + 889 => -2840789983034124546, + 890 => -3354685848773275680, + 891 => -1723442823480586914, + 892 => -4806374104368124616, + 893 => 5841356859396356176, + 894 => 508357292543715601, + 895 => -8060514273610414272, + 896 => -799229186262249902, + 897 => 2877849229494537950, + 898 => -4469006376519612559, + 899 => 762642128687348774, + 900 => 3588789175675451971, + 901 => -8849709859862152666, + 902 => 8575850026410500273, + 903 => -3882861293540321843, + 904 => 2362261680537362722, + 905 => -1984586947110927454, + 906 => 3253859884740030522, + 907 => 8022132794119030823, + 908 => 2755083524648425779, + 909 => -5741280240352423818, + 910 => -3431028027852582513, + 911 => 3551914327964688721, + 912 => -7781962082361363318, + 913 => -5149102934125081290, + 914 => 8764647311272413826, + 915 => 4832145771203934497, + 916 => -4904446247206020211, + 917 => 6441731183741810927, + 918 => -6060411740430596086, + 919 => 1015647392864421793, + 920 => -1899175577452626000, + 921 => -8824089357560460450, + 922 => 5076969182290891584, + 923 => -2886902515647455214, + 924 => 8162196046706760127, + 925 => -6101262665834660182, + 926 => -135644501089363711, + 927 => -2717776315021831080, + 928 => -1225820791730929786, + 929 => -2543291547514274494, + 930 => 1236843312118227402, + 931 => 5383036634794926737, + 932 => 3621634061120232613, + 933 => 7581808175887087760, + 934 => 7732561353971308437, + 935 => -769827589121750359, + 936 => -1400439143539382496, + 937 => -301252394331355107, + 938 => 7034340125714281556, + 939 => -662471733306487756, + 940 => -7557352272589358112, + 941 => -9203713532702920147, + 942 => 5203772156086473502, + 943 => 2995125955123057037, + 944 => 8278668579692439832, + 945 => 6406503897815248551, + 946 => -8783312910216256464, + 947 => -8414856455170238684, + 948 => 199025223093326220, + 949 => 5470495000161012160, + 950 => 3104230518788455532, + 951 => -765386468698267359, + 952 => 4361395450210599155, + 953 => -3086964391909231663, + 954 => -5390964443116204656, + 955 => -8104413485721822709, + 956 => -5513399624850018243, + 957 => 3910788381801006263, + 958 => -5699313055370250965, + 959 => -6980140912659582482, + 960 => -5212140192577220982, + 961 => 2816767385968649045, + 962 => 1738667790038600161, + 963 => -900487993662467339, + 964 => 7451525460473151658, + 965 => -6577652361625746608, + 966 => -728802060191413007, + 967 => -3000963813011923874, + 968 => 2409767179539829923, + 969 => -9205398318637230327, + 970 => 3352185647164828069, + 971 => 929287429705404222, + 972 => -1935661750391601595, + 973 => 4907515611453535642, + 974 => 991763148255042634, + 975 => 9211322673922781230, + 976 => -4056233821525283506, + 977 => -8172867281523911365, + 978 => 2491297239385952127, + 979 => 7167975622581645303, + 980 => 4753230918151890989, + 981 => -8719321975173591025, + 982 => -1795406061378902577, + 983 => -2709572863074161296, + 984 => -3010079518298475214, + 985 => 3982255536584210398, + 986 => 2463559347523487796, + 987 => 2218073750032620742, + 988 => -2312771975564260983, + 989 => 1476263447905776349, + 990 => 7183419630152279613, + 991 => 3353963567092417736, + 992 => 7584439691865372095, + 993 => -3073536873323287273, + 994 => -397561346574583857, + 995 => 78386691422419006, + 996 => -8119215953105509619, + 997 => -4578854324907769257, + 998 => 7195056868313381403, + 999 => 5692761090142998691, +); + +$rng = new \RNG\MT19937(SEED); +foreach ($result as $ret) { + $rng_next = $rng->next64(); + if ($ret !== $rng_next) { + die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); + } +} + +die('OK, Result is consistent.'); +?> +--EXPECT-- +OK, Result is consistent. diff --git a/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt b/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt new file mode 100644 index 0000000000000..aa32fc935ac33 --- /dev/null +++ b/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test class: MT19937: unexcepted __unserialize(). +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Exception: Incomplete or ill-formed serialization data in %s:%i +Stack trace: +#0 [internal function]: %s->__unserialize(Array) +#1 %s(%i): unserialize('%s') +#2 {main} + thrown in %s on line %i diff --git a/ext/standard/tests/rng/xorshift128plus_result.phpt b/ext/standard/tests/rng/xorshift128plus_result.phpt new file mode 100644 index 0000000000000..c3ba52f62007e --- /dev/null +++ b/ext/standard/tests/rng/xorshift128plus_result.phpt @@ -0,0 +1,1021 @@ +--TEST-- +Test class: XorShift128Plus: consistent result. +--FILE-- + 1349682502, + 1 => 2037461237, + 2 => 373945879, + 3 => 44750090, + 4 => 1935940315, + 5 => 735742043, + 6 => 93019629, + 7 => 1466689789, + 8 => 1423653722, + 9 => 502197902, + 10 => 460412399, + 11 => 922348448, + 12 => 873565626, + 13 => 139489342, + 14 => 149227930, + 15 => 1891076085, + 16 => 229394502, + 17 => 1255504052, + 18 => 1872845800, + 19 => 2144170108, + 20 => 1864453191, + 21 => 720454379, + 22 => 450499804, + 23 => 1303829853, + 24 => 1352374341, + 25 => 628524765, + 26 => 721623023, + 27 => 1435526393, + 28 => 401905342, + 29 => 219807123, + 30 => 28354555, + 31 => 305427439, + 32 => 2128930528, + 33 => 927919172, + 34 => 118834996, + 35 => 1926861238, + 36 => 206257091, + 37 => 1885169722, + 38 => 147757932, + 39 => 1523782473, + 40 => 19299303, + 41 => 1620661898, + 42 => 800997487, + 43 => 883832846, + 44 => 108062443, + 45 => 1064953420, + 46 => 907984430, + 47 => 1956899472, + 48 => 1221868336, + 49 => 1454807928, + 50 => 898490527, + 51 => 1257344739, + 52 => 1607689731, + 53 => 814227587, + 54 => 1878815558, + 55 => 1310241740, + 56 => 1790693690, + 57 => 1996192732, + 58 => 626471770, + 59 => 1365221195, + 60 => 59540294, + 61 => 106545988, + 62 => 2035836508, + 63 => 543177385, + 64 => 200819823, + 65 => 676715151, + 66 => 456979891, + 67 => 1499012915, + 68 => 1730006818, + 69 => 397939547, + 70 => 1125642388, + 71 => 2021902389, + 72 => 393910208, + 73 => 572899813, + 74 => 266986984, + 75 => 1011230820, + 76 => 1589795176, + 77 => 1082956695, + 78 => 2043395554, + 79 => 187847379, + 80 => 1156057772, + 81 => 758487253, + 82 => 626405718, + 83 => 429737375, + 84 => 994670207, + 85 => 1682757791, + 86 => 557433865, + 87 => 1489666276, + 88 => 868576512, + 89 => 1149413952, + 90 => 2032482078, + 91 => 765685082, + 92 => 740673853, + 93 => 1305008162, + 94 => 1517942381, + 95 => 522045930, + 96 => 1088113262, + 97 => 1834508497, + 98 => 1225013478, + 99 => 236929758, + 100 => 991301230, + 101 => 726833918, + 102 => 732727572, + 103 => 1418296210, + 104 => 266746438, + 105 => 1627563451, + 106 => 1032020068, + 107 => 1962248028, + 108 => 1226887363, + 109 => 527674563, + 110 => 454131287, + 111 => 1107351732, + 112 => 1139552078, + 113 => 1776148727, + 114 => 917857149, + 115 => 767868630, + 116 => 1946098486, + 117 => 1030808578, + 118 => 1558133393, + 119 => 642988847, + 120 => 2025887068, + 121 => 1202682960, + 122 => 1710072676, + 123 => 244856979, + 124 => 1504691016, + 125 => 857074347, + 126 => 460321260, + 127 => 1148438808, + 128 => 1347550774, + 129 => 101249884, + 130 => 2077162612, + 131 => 1361419276, + 132 => 1997760750, + 133 => 159855873, + 134 => 231725849, + 135 => 1166501717, + 136 => 156989547, + 137 => 390151435, + 138 => 178398072, + 139 => 384600556, + 140 => 1678625854, + 141 => 928462153, + 142 => 362200398, + 143 => 2140861704, + 144 => 829774976, + 145 => 1575598789, + 146 => 1348474917, + 147 => 1189907696, + 148 => 709163516, + 149 => 1928761530, + 150 => 470725610, + 151 => 749335811, + 152 => 1491682862, + 153 => 887119881, + 154 => 1534326460, + 155 => 165694813, + 156 => 666546613, + 157 => 1274162092, + 158 => 1318638737, + 159 => 53985760, + 160 => 1380111560, + 161 => 175440944, + 162 => 1785363040, + 163 => 1338976810, + 164 => 928526647, + 165 => 152263930, + 166 => 1506516920, + 167 => 218555336, + 168 => 40722171, + 169 => 2045830825, + 170 => 1673727835, + 171 => 1245338230, + 172 => 862164732, + 173 => 2012167047, + 174 => 1578309398, + 175 => 177550798, + 176 => 248233468, + 177 => 214644185, + 178 => 282497075, + 179 => 464809110, + 180 => 537415711, + 181 => 1924408863, + 182 => 982622427, + 183 => 1429563204, + 184 => 183028435, + 185 => 1370189782, + 186 => 1335729368, + 187 => 121000075, + 188 => 1823582007, + 189 => 950675763, + 190 => 1998837572, + 191 => 1376340021, + 192 => 1872322636, + 193 => 281730652, + 194 => 149173774, + 195 => 339298481, + 196 => 347552970, + 197 => 861537873, + 198 => 184202850, + 199 => 1322671301, + 200 => 1281690460, + 201 => 1361356712, + 202 => 2089176324, + 203 => 367010071, + 204 => 893900736, + 205 => 1343932562, + 206 => 1526746460, + 207 => 2144504048, + 208 => 1580670635, + 209 => 2042274141, + 210 => 531270359, + 211 => 1714688895, + 212 => 291346735, + 213 => 1669612651, + 214 => 846534526, + 215 => 11854546, + 216 => 1238955925, + 217 => 1419425319, + 218 => 1216894752, + 219 => 21003472, + 220 => 589068236, + 221 => 485938370, + 222 => 2006184907, + 223 => 2085539788, + 224 => 1016547051, + 225 => 366274733, + 226 => 73491987, + 227 => 590683095, + 228 => 1371346496, + 229 => 761730785, + 230 => 586074960, + 231 => 68351609, + 232 => 1567351038, + 233 => 450713539, + 234 => 87290873, + 235 => 1246887498, + 236 => 59759579, + 237 => 451300781, + 238 => 1066224192, + 239 => 813233613, + 240 => 1952790187, + 241 => 476313723, + 242 => 1442194032, + 243 => 1499472228, + 244 => 370899064, + 245 => 496911926, + 246 => 1419634540, + 247 => 1242616718, + 248 => 1774249481, + 249 => 1329615449, + 250 => 1386336381, + 251 => 274340096, + 252 => 504466789, + 253 => 117665196, + 254 => 152033506, + 255 => 559001760, + 256 => 1590272045, + 257 => 113498200, + 258 => 1373197278, + 259 => 967968985, + 260 => 689931910, + 261 => 1097666144, + 262 => 639847767, + 263 => 1253236113, + 264 => 871577681, + 265 => 1583303241, + 266 => 1452457793, + 267 => 639946114, + 268 => 1852573616, + 269 => 57670947, + 270 => 860328804, + 271 => 1472385105, + 272 => 1528553648, + 273 => 2100880928, + 274 => 184924997, + 275 => 1753333376, + 276 => 796541800, + 277 => 1370438034, + 278 => 967463174, + 279 => 295327597, + 280 => 666290413, + 281 => 1038636422, + 282 => 738715569, + 283 => 1515082278, + 284 => 401893629, + 285 => 1236436229, + 286 => 2106314431, + 287 => 2082175520, + 288 => 533351387, + 289 => 1166859949, + 290 => 108038014, + 291 => 1897329746, + 292 => 192287421, + 293 => 219324086, + 294 => 2023098313, + 295 => 1647682034, + 296 => 1780616538, + 297 => 2117427941, + 298 => 660400657, + 299 => 216307887, + 300 => 317252299, + 301 => 217730516, + 302 => 1822558512, + 303 => 402834402, + 304 => 2096616772, + 305 => 773925891, + 306 => 1369081309, + 307 => 1823176911, + 308 => 1169733177, + 309 => 52007222, + 310 => 4430116, + 311 => 807696130, + 312 => 2057713136, + 313 => 966681892, + 314 => 1726784345, + 315 => 1064353562, + 316 => 45285903, + 317 => 789948436, + 318 => 869400101, + 319 => 868937894, + 320 => 338915118, + 321 => 425609744, + 322 => 1508258107, + 323 => 2146838772, + 324 => 857891611, + 325 => 1597149334, + 326 => 577569099, + 327 => 293795070, + 328 => 1839143191, + 329 => 811610234, + 330 => 1884853812, + 331 => 1434629539, + 332 => 1943749563, + 333 => 1043727841, + 334 => 977216688, + 335 => 1048088444, + 336 => 2022374565, + 337 => 1752634595, + 338 => 317413896, + 339 => 2090660981, + 340 => 547033326, + 341 => 754791498, + 342 => 1326519097, + 343 => 1044669356, + 344 => 547042374, + 345 => 1056626199, + 346 => 209098801, + 347 => 1733864465, + 348 => 875131093, + 349 => 1150080047, + 350 => 864043712, + 351 => 40739817, + 352 => 1615640456, + 353 => 979508232, + 354 => 2060380613, + 355 => 155731010, + 356 => 1549870241, + 357 => 358658324, + 358 => 581736831, + 359 => 178950253, + 360 => 1062755495, + 361 => 1426837730, + 362 => 1399724011, + 363 => 1186598366, + 364 => 617984179, + 365 => 144972251, + 366 => 338030430, + 367 => 579726922, + 368 => 711183530, + 369 => 1952490045, + 370 => 2066817099, + 371 => 457769878, + 372 => 1252077930, + 373 => 187580692, + 374 => 253070839, + 375 => 120157234, + 376 => 529745058, + 377 => 1379610391, + 378 => 1032896380, + 379 => 719362005, + 380 => 1720513442, + 381 => 124212254, + 382 => 1969350511, + 383 => 737222986, + 384 => 2018894483, + 385 => 362497545, + 386 => 2099049676, + 387 => 1909131972, + 388 => 1155289370, + 389 => 61180063, + 390 => 887891858, + 391 => 2095180477, + 392 => 1981532921, + 393 => 1422771317, + 394 => 1186320535, + 395 => 1911029659, + 396 => 322956107, + 397 => 1813050951, + 398 => 1683060121, + 399 => 1972082392, + 400 => 689339402, + 401 => 1768641740, + 402 => 1542069628, + 403 => 1603998225, + 404 => 1823175419, + 405 => 2050041622, + 406 => 848284884, + 407 => 1410901178, + 408 => 1721097938, + 409 => 619389779, + 410 => 1327785409, + 411 => 55288900, + 412 => 1265016343, + 413 => 1392500541, + 414 => 625962482, + 415 => 1205517923, + 416 => 603955731, + 417 => 1216315955, + 418 => 1029498557, + 419 => 1158577239, + 420 => 2027251122, + 421 => 1771616242, + 422 => 759730795, + 423 => 2111568143, + 424 => 1112431009, + 425 => 1438606842, + 426 => 1235386742, + 427 => 1562774897, + 428 => 317226972, + 429 => 1155982434, + 430 => 1258029607, + 431 => 1932616754, + 432 => 1445981500, + 433 => 1260780929, + 434 => 1606189713, + 435 => 1075919686, + 436 => 1313678376, + 437 => 672041741, + 438 => 1642353333, + 439 => 2121261410, + 440 => 1282322050, + 441 => 150443960, + 442 => 384505621, + 443 => 1242831968, + 444 => 81948703, + 445 => 1245502429, + 446 => 302262179, + 447 => 1069009779, + 448 => 1460572866, + 449 => 1919954617, + 450 => 225565850, + 451 => 466618362, + 452 => 606253805, + 453 => 141813669, + 454 => 238164155, + 455 => 831581237, + 456 => 363203846, + 457 => 1580549988, + 458 => 1877164893, + 459 => 1382767661, + 460 => 1157552498, + 461 => 1377040490, + 462 => 817392678, + 463 => 1905664115, + 464 => 1274076594, + 465 => 1195852831, + 466 => 1689854475, + 467 => 1721526559, + 468 => 1265208053, + 469 => 1314167336, + 470 => 1491182462, + 471 => 528475610, + 472 => 134481837, + 473 => 2030901943, + 474 => 968984052, + 475 => 467914715, + 476 => 868882509, + 477 => 1452500366, + 478 => 1850912628, + 479 => 118908032, + 480 => 2058238361, + 481 => 644820146, + 482 => 133224220, + 483 => 798949092, + 484 => 1836532095, + 485 => 1854498801, + 486 => 1116997517, + 487 => 2031689471, + 488 => 982822820, + 489 => 1313832983, + 490 => 1253419260, + 491 => 355569720, + 492 => 981975001, + 493 => 1737748888, + 494 => 2053715712, + 495 => 1640034855, + 496 => 1689953581, + 497 => 1028409662, + 498 => 1767492008, + 499 => 370133373, + 500 => 1770016629, + 501 => 1824789670, + 502 => 1186422143, + 503 => 58424003, + 504 => 568100562, + 505 => 1627141439, + 506 => 1257283105, + 507 => 412577377, + 508 => 1252711300, + 509 => 725810768, + 510 => 667360467, + 511 => 294408980, + 512 => 1995610969, + 513 => 805801548, + 514 => 695749558, + 515 => 1889625442, + 516 => 1349896415, + 517 => 1493631562, + 518 => 729790265, + 519 => 1046837006, + 520 => 470859179, + 521 => 1865662344, + 522 => 389291854, + 523 => 1438910365, + 524 => 307559532, + 525 => 885429628, + 526 => 170533914, + 527 => 464985554, + 528 => 280414803, + 529 => 1886446813, + 530 => 182303851, + 531 => 1154967954, + 532 => 895899503, + 533 => 1861305778, + 534 => 1285644348, + 535 => 365438352, + 536 => 1385404739, + 537 => 1220484757, + 538 => 1686399523, + 539 => 1850298416, + 540 => 582728819, + 541 => 499982552, + 542 => 2107114013, + 543 => 1961004529, + 544 => 1858065048, + 545 => 1937334915, + 546 => 907555009, + 547 => 1747711832, + 548 => 1378121920, + 549 => 641906572, + 550 => 1309227, + 551 => 218137964, + 552 => 1386384841, + 553 => 562538100, + 554 => 1411442996, + 555 => 194175416, + 556 => 1467413102, + 557 => 227548643, + 558 => 1519169996, + 559 => 1171115272, + 560 => 923143666, + 561 => 1900503163, + 562 => 518854434, + 563 => 136505431, + 564 => 320456571, + 565 => 149028309, + 566 => 790180243, + 567 => 1699714463, + 568 => 1052347131, + 569 => 2002033400, + 570 => 1726553092, + 571 => 1818475203, + 572 => 553804998, + 573 => 1669874249, + 574 => 315845465, + 575 => 119118882, + 576 => 711459994, + 577 => 597299061, + 578 => 1698182666, + 579 => 1305041534, + 580 => 142578045, + 581 => 1851652602, + 582 => 489547536, + 583 => 1362204218, + 584 => 1095093138, + 585 => 1162138282, + 586 => 1126120622, + 587 => 1405707178, + 588 => 557858536, + 589 => 821884018, + 590 => 2141202567, + 591 => 1658956006, + 592 => 1686405526, + 593 => 691154173, + 594 => 346564298, + 595 => 263508694, + 596 => 1067899145, + 597 => 1940533426, + 598 => 212369399, + 599 => 770991770, + 600 => 1160535771, + 601 => 352771226, + 602 => 662247506, + 603 => 1219095652, + 604 => 55431646, + 605 => 2091964740, + 606 => 1743686910, + 607 => 437700695, + 608 => 1258217215, + 609 => 2089586975, + 610 => 1416227824, + 611 => 556787290, + 612 => 1630274307, + 613 => 766448700, + 614 => 2027339755, + 615 => 522016275, + 616 => 1444124531, + 617 => 774693450, + 618 => 269433345, + 619 => 1827800225, + 620 => 1033739916, + 621 => 662568600, + 622 => 1493272757, + 623 => 431177711, + 624 => 1409430064, + 625 => 1855900384, + 626 => 1946645313, + 627 => 1607316817, + 628 => 822557192, + 629 => 990038940, + 630 => 2072180193, + 631 => 238723231, + 632 => 1164780106, + 633 => 882192368, + 634 => 486727594, + 635 => 1410387521, + 636 => 1578980430, + 637 => 218294240, + 638 => 1823161904, + 639 => 1976945957, + 640 => 721792341, + 641 => 1239371504, + 642 => 1564547465, + 643 => 73009331, + 644 => 1832302237, + 645 => 370619154, + 646 => 1338048121, + 647 => 2140756492, + 648 => 119420571, + 649 => 1602694284, + 650 => 17968547, + 651 => 394254946, + 652 => 816048090, + 653 => 1840351020, + 654 => 1525210066, + 655 => 862797919, + 656 => 603980768, + 657 => 1704084601, + 658 => 150799721, + 659 => 568165108, + 660 => 1626775664, + 661 => 357597789, + 662 => 1694957546, + 663 => 210053987, + 664 => 731866758, + 665 => 1556485118, + 666 => 747180784, + 667 => 1432728644, + 668 => 421809179, + 669 => 1784292342, + 670 => 967406764, + 671 => 1054670363, + 672 => 166387124, + 673 => 552559492, + 674 => 325031439, + 675 => 420630319, + 676 => 460145521, + 677 => 364851539, + 678 => 292153910, + 679 => 860779220, + 680 => 887097679, + 681 => 973139335, + 682 => 800424739, + 683 => 1008609442, + 684 => 1194932386, + 685 => 1286438298, + 686 => 154048207, + 687 => 1872289159, + 688 => 2011948053, + 689 => 1249137369, + 690 => 168391850, + 691 => 1201420754, + 692 => 1756609837, + 693 => 167807088, + 694 => 936287075, + 695 => 307106424, + 696 => 467084202, + 697 => 246826733, + 698 => 977333363, + 699 => 1016411415, + 700 => 321068680, + 701 => 210750101, + 702 => 2134002548, + 703 => 674459800, + 704 => 460853557, + 705 => 1414693125, + 706 => 1278387317, + 707 => 1277691050, + 708 => 987704383, + 709 => 1906514190, + 710 => 1504521139, + 711 => 1236199367, + 712 => 487494576, + 713 => 2094311668, + 714 => 784397602, + 715 => 618095115, + 716 => 1093882767, + 717 => 1432355921, + 718 => 1241195151, + 719 => 1721272133, + 720 => 1410040136, + 721 => 1217654854, + 722 => 832301322, + 723 => 1892860148, + 724 => 1733195675, + 725 => 855599393, + 726 => 723586039, + 727 => 485943865, + 728 => 982016063, + 729 => 2122422938, + 730 => 711086996, + 731 => 390533590, + 732 => 564354372, + 733 => 2030541430, + 734 => 408769972, + 735 => 1039759054, + 736 => 101406381, + 737 => 240672601, + 738 => 1913885042, + 739 => 420234709, + 740 => 1638165908, + 741 => 90215095, + 742 => 1431419796, + 743 => 42000709, + 744 => 100071503, + 745 => 882980765, + 746 => 1797122366, + 747 => 904504375, + 748 => 663002819, + 749 => 835813658, + 750 => 953262159, + 751 => 1864662799, + 752 => 947721009, + 753 => 372773118, + 754 => 466139801, + 755 => 729667839, + 756 => 811375371, + 757 => 2102400904, + 758 => 827586405, + 759 => 620654951, + 760 => 1264108501, + 761 => 2057677059, + 762 => 1579361768, + 763 => 83182000, + 764 => 1809987362, + 765 => 144118324, + 766 => 806357999, + 767 => 1006040486, + 768 => 1928991891, + 769 => 532429019, + 770 => 678645528, + 771 => 317543446, + 772 => 353233153, + 773 => 563876761, + 774 => 1244781985, + 775 => 1050110040, + 776 => 1148022165, + 777 => 1297168089, + 778 => 465116364, + 779 => 95655662, + 780 => 2114470143, + 781 => 1445629333, + 782 => 987629236, + 783 => 1009053565, + 784 => 157080941, + 785 => 1729660507, + 786 => 1537856571, + 787 => 346094015, + 788 => 1070316332, + 789 => 280211436, + 790 => 113139896, + 791 => 1755416975, + 792 => 1562690019, + 793 => 411279151, + 794 => 780393226, + 795 => 1863424738, + 796 => 2028623631, + 797 => 180245248, + 798 => 1519975972, + 799 => 433968591, + 800 => 1522370361, + 801 => 1072766235, + 802 => 1856028598, + 803 => 675519719, + 804 => 1305432982, + 805 => 603576792, + 806 => 1016238860, + 807 => 1505359743, + 808 => 1893531686, + 809 => 2084084003, + 810 => 1461898463, + 811 => 437160906, + 812 => 137780557, + 813 => 2033778757, + 814 => 1017429675, + 815 => 1437843420, + 816 => 731942285, + 817 => 1899218357, + 818 => 1449371449, + 819 => 1389738284, + 820 => 1920521078, + 821 => 24089631, + 822 => 570905115, + 823 => 1505148551, + 824 => 1772002662, + 825 => 126300577, + 826 => 1518053444, + 827 => 2025713559, + 828 => 1801525056, + 829 => 905932446, + 830 => 1918825555, + 831 => 1188695816, + 832 => 640254049, + 833 => 1872761135, + 834 => 1098659478, + 835 => 1086939672, + 836 => 1180851818, + 837 => 2065843915, + 838 => 348300832, + 839 => 2057822649, + 840 => 854713329, + 841 => 1508858718, + 842 => 125705502, + 843 => 1125340519, + 844 => 1082447091, + 845 => 834814040, + 846 => 64645087, + 847 => 1279264088, + 848 => 1657135580, + 849 => 1268279155, + 850 => 380695444, + 851 => 1121390162, + 852 => 1985762087, + 853 => 1281949838, + 854 => 635530873, + 855 => 1413428474, + 856 => 1900667995, + 857 => 1152357472, + 858 => 215724983, + 859 => 957827456, + 860 => 587561335, + 861 => 34880762, + 862 => 467663223, + 863 => 1646935425, + 864 => 49072574, + 865 => 89464159, + 866 => 1006786236, + 867 => 1102515725, + 868 => 280447544, + 869 => 332734514, + 870 => 852003278, + 871 => 476255128, + 872 => 1682542261, + 873 => 1778648146, + 874 => 129794495, + 875 => 2015791517, + 876 => 535201245, + 877 => 924524250, + 878 => 1316084820, + 879 => 946872889, + 880 => 1080923065, + 881 => 713226697, + 882 => 1684751638, + 883 => 46700267, + 884 => 186119421, + 885 => 1350441122, + 886 => 1890883596, + 887 => 56105439, + 888 => 1231537555, + 889 => 1566756009, + 890 => 1220439163, + 891 => 1088126234, + 892 => 488448872, + 893 => 2134839416, + 894 => 1968631520, + 895 => 1893885873, + 896 => 296514507, + 897 => 1869816965, + 898 => 1642656100, + 899 => 52255521, + 900 => 1960509278, + 901 => 696181825, + 902 => 617710744, + 903 => 1610702431, + 904 => 1931274498, + 905 => 1293539108, + 906 => 1154784580, + 907 => 1019984228, + 908 => 871534774, + 909 => 1175543804, + 910 => 1395930730, + 911 => 630063042, + 912 => 228974016, + 913 => 1988079375, + 914 => 463309620, + 915 => 1431833465, + 916 => 1928175220, + 917 => 1756580353, + 918 => 817417518, + 919 => 1547255861, + 920 => 1358486291, + 921 => 1307537767, + 922 => 1098390415, + 923 => 758475648, + 924 => 2065528313, + 925 => 113508798, + 926 => 2085342662, + 927 => 1989125191, + 928 => 54928278, + 929 => 1922285522, + 930 => 963466727, + 931 => 2054929297, + 932 => 152202861, + 933 => 1200041146, + 934 => 1388458844, + 935 => 617594305, + 936 => 926707155, + 937 => 2016750893, + 938 => 1148235120, + 939 => 1344997085, + 940 => 1559634028, + 941 => 25457468, + 942 => 835499343, + 943 => 172745143, + 944 => 1641026504, + 945 => 1136801806, + 946 => 591248427, + 947 => 33097530, + 948 => 798815637, + 949 => 1612009106, + 950 => 509622931, + 951 => 1202848691, + 952 => 145973872, + 953 => 801603533, + 954 => 311928117, + 955 => 1943150090, + 956 => 1107330499, + 957 => 1386493680, + 958 => 1606163304, + 959 => 145315043, + 960 => 1903127277, + 961 => 1230522895, + 962 => 416625176, + 963 => 97830298, + 964 => 1019942542, + 965 => 957881582, + 966 => 199517278, + 967 => 72740614, + 968 => 18272760, + 969 => 760052286, + 970 => 291094570, + 971 => 1911286480, + 972 => 1778820125, + 973 => 671612677, + 974 => 828399010, + 975 => 1998974668, + 976 => 1920269016, + 977 => 2006102160, + 978 => 1653660350, + 979 => 234234283, + 980 => 1578859339, + 981 => 1279878591, + 982 => 1880095534, + 983 => 1709693199, + 984 => 930838451, + 985 => 1503156349, + 986 => 1075718196, + 987 => 1156095068, + 988 => 1257151272, + 989 => 1663593956, + 990 => 1845111613, + 991 => 1069548880, + 992 => 1306416912, + 993 => 55076428, + 994 => 1630631614, + 995 => 204743002, + 996 => 1944013283, + 997 => 610599117, + 998 => 2028398528, + 999 => 1271124722, +); + +$rng = new \RNG\XorShift128Plus(SEED); +foreach ($result as $ret) { + $rng_next = rng_rand($rng); + if ($ret !== $rng_next) { + die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); + } +} + +die('OK, Result is consistent.'); +?> +--EXPECT-- +OK, Result is consistent. diff --git a/ext/standard/tests/rng/xorshift128plus_result_64.phpt b/ext/standard/tests/rng/xorshift128plus_result_64.phpt new file mode 100644 index 0000000000000..77c44cc09f358 --- /dev/null +++ b/ext/standard/tests/rng/xorshift128plus_result_64.phpt @@ -0,0 +1,1027 @@ +--TEST-- +Test class: XorShift128Plus: consistent result in 64bit range. +--SKIPIF-- + +--FILE-- +next64(); } var_export($arr);' +$result = array ( + 0 => 6233086606872742541, + 1 => 8068093359486558699, + 2 => -5167171210566177746, + 3 => 7067430833834273300, + 4 => 5869501872498816438, + 5 => 8546184145333981366, + 6 => -7675341174649472037, + 7 => -5438916696891469318, + 8 => 805546558303401653, + 9 => -1549078639761564387, + 10 => -7947959769147200545, + 11 => 4238051778512541505, + 12 => -3355517432467612811, + 13 => 2534162508875358333, + 14 => -5169366708103015627, + 15 => 7622337846211186667, + 16 => -2843892751838703475, + 17 => -9169669279398039191, + 18 => 6672454254697035728, + 19 => 980861210597187832, + 20 => -2947025856922216306, + 21 => -2876937829800049194, + 22 => 5378361677646670264, + 23 => 6402376320460634810, + 24 => -3112745002104049525, + 25 => 7815704014450658747, + 26 => 1362205306649980894, + 27 => 1968397761034373619, + 28 => -3884701032555926147, + 29 => 9035062408836807463, + 30 => 3735692176783396855, + 31 => 238903888548784095, + 32 => -1547687286147527232, + 33 => -327747487918073720, + 34 => -4957213332539273623, + 35 => -8987780780324084884, + 36 => 7279061022635620231, + 37 => 6833462932152176756, + 38 => 4549426172800087769, + 39 => -4973794557781727597, + 40 => -526506095019231282, + 41 => 2235751933618072853, + 42 => 7858298588449505503, + 43 => -8584081284247293923, + 44 => -7887380617646453290, + 45 => -801559887372628839, + 46 => -3617803946929849252, + 47 => -7967077348488522463, + 48 => 9193227545043564129, + 49 => 4108913838247458545, + 50 => -2343931640686067394, + 51 => 3663807406097505734, + 52 => -7023588444321952761, + 53 => 4145043411097895175, + 54 => 6607570033444447885, + 55 => -6885783092079794279, + 56 => 5613946615107134069, + 57 => 1042743975275329464, + 58 => -8880377862898686283, + 59 => -8664205809451843946, + 60 => 3894109949614687885, + 61 => 3511737541150869129, + 62 => 6400129353949170872, + 63 => 6965486229827646802, + 64 => -1614484618550933281, + 65 => 1486137421109900574, + 66 => -6584711946535572634, + 67 => -4130422719320539545, + 68 => -847253235650814396, + 69 => 8903455639056950966, + 70 => 7024659691941650728, + 71 => -4118196956427743125, + 72 => -3234872081255157887, + 73 => -3164660236169804854, + 74 => 7422910021644831697, + 75 => 8771490394997018825, + 76 => 6798485190349206224, + 77 => -2028541901030213841, + 78 => -6453336362726229052, + 79 => -4778723017089571418, + 80 => -5798499399712631463, + 81 => 5731049845555933611, + 82 => 6662887178192577197, + 83 => -3388473494806557889, + 84 => -5139491467951936257, + 85 => -5038018771103928001, + 86 => 2158430451305515027, + 87 => -3688233498091126328, + 88 => -8792995464287168000, + 89 => 1359803583268476033, + 90 => -6052703011673051588, + 91 => -976225281502684492, + 92 => -3185708908479278470, + 93 => -16113752611901372, + 94 => -2572201364453856038, + 95 => -7864440779878722603, + 96 => -294441446441315108, + 97 => 414333712007741859, + 98 => -7930716040860241460, + 99 => 8619013226169796028, + 100 => -4202414296431584036, + 101 => -2343016349138864644, + 102 => -2044263328869969367, + 103 => 8089952478337103652, + 104 => -585397951647681395, + 105 => 2036354567926795127, + 106 => -3629057568451149623, + 107 => -620120117439951175, + 108 => -8006071254949715577, + 109 => -7273790937381774969, + 110 => -2681075441755554641, + 111 => 1844472049624527208, + 112 => 5055321696745578140, + 113 => -953286305830419985, + 114 => -7896578919851440390, + 115 => -5942918302882234964, + 116 => -3633818902942828948, + 117 => 6133200497452107780, + 118 => -103538567329975006, + 119 => -2533939224349090, + 120 => -1424892818446275911, + 121 => 4370577474642180257, + 122 => 1189510330126649032, + 123 => 8312511900242964775, + 124 => 1672650990389528209, + 125 => -2392028076118911657, + 126 => 7594315045759083481, + 127 => 2014190143424401968, + 128 => -3296960212478198676, + 129 => -7889768735440771399, + 130 => -3214911664057091864, + 131 => -3315075499741726696, + 132 => -5937641061220953635, + 133 => -8409365331808720382, + 134 => -8098312379770620366, + 135 => -6997572329348870486, + 136 => -1505822663309332265, + 137 => -3211177253496784362, + 138 => 897815089124755184, + 139 => -7431939192649083944, + 140 => -7649604383115863939, + 141 => -3096433820968260974, + 142 => -6503366919701300580, + 143 => -4910219149257086447, + 144 => -898559130062898943, + 145 => 6181990163088110987, + 146 => 153062574018015307, + 147 => -3402824860217828895, + 148 => -5128512071825492999, + 149 => 9194357913130180980, + 150 => 960481574545876949, + 151 => 8374922126864673287, + 152 => -2966485336578683811, + 153 => 222603101549412370, + 154 => -8392610021687956103, + 155 => 4608733847218068155, + 156 => -2152136474932976790, + 157 => 2312268905607092057, + 158 => -2932732821033080541, + 159 => -2595244369435982912, + 160 => -8859418541246010991, + 161 => 2987843757009406049, + 162 => -8263775768403446591, + 163 => 7956517580982604885, + 164 => -4855086198396263825, + 165 => -508357658904446476, + 166 => -3866150645688483983, + 167 => 9152901218921465745, + 168 => 8897302951662108151, + 169 => 7287054514503404883, + 170 => -2722862352960184650, + 171 => -5343479560489618196, + 172 => 7807084719929503224, + 173 => 7300647471747593999, + 174 => 2684475586745085484, + 175 => -1325083438655837283, + 176 => -3192540574639490056, + 177 => -5097580822155334733, + 178 => -3835928535232602010, + 179 => -819597750488737491, + 180 => -4256127033789079489, + 181 => 4230186832109259838, + 182 => -301086512678485577, + 183 => -9141693794819060088, + 184 => -3701409747403958874, + 185 => 4004433656181874604, + 186 => 4662227143243807153, + 187 => 8265173367459193111, + 188 => -6872268542664552850, + 189 => -368254286513810841, + 190 => 5260534621686705801, + 191 => 6641868644832940139, + 192 => 2768722268492316825, + 193 => -5681941453701006152, + 194 => 7900162273330097180, + 195 => -3935494402550361757, + 196 => -297196673737786987, + 197 => -2218494427935798109, + 198 => -8585051849471202107, + 199 => 1189254491034925451, + 200 => 305201422294193849, + 201 => -7334571942792835247, + 202 => 2967579379284875785, + 203 => -3764933945431408081, + 204 => 6807938953141792641, + 205 => 6042179712895521060, + 206 => -4687158022512797000, + 207 => -5582265326438641183, + 208 => 4522899856350395734, + 209 => 7669896904145453755, + 210 => -6684219449507768914, + 211 => -676763327750723841, + 212 => 2879997055424213598, + 213 => -2664579015401502506, + 214 => -6102005420377100548, + 215 => -8083997683709524572, + 216 => 1215494657986916139, + 217 => -1972053395263624114, + 218 => -3352733695972692415, + 219 => -2749431011073787488, + 220 => 5156465409506471832, + 221 => -837693036075046523, + 222 => -6445889520869578857, + 223 => 2403718291494117273, + 224 => 7290825940407324119, + 225 => -3797103220415147685, + 226 => 1913161382212324391, + 227 => -5250288546821294161, + 228 => 801489540680920193, + 229 => 55816928350842307, + 230 => -5189097228641397087, + 231 => -7418994264930652941, + 232 => 3111998697246278141, + 233 => -7658555071646748793, + 234 => 2443258963310405618, + 235 => -1455653740850447211, + 236 => 6462754302499731382, + 237 => -7390965621123671206, + 238 => 2059181699507065984, + 239 => -7830135668617385061, + 240 => 551861004603649367, + 241 => -28505787185237769, + 242 => -6111755252645739296, + 243 => -2786692911721332024, + 244 => -5431530429075754767, + 245 => 3859506090475293804, + 246 => -607806511712055592, + 247 => -1604928790975109348, + 248 => -6919237020917052398, + 249 => 1659823400194974898, + 250 => 3260109291172110587, + 251 => 7103660588537229825, + 252 => 2868540883423402698, + 253 => -6973595968574399656, + 254 => -3010740476117536316, + 255 => 5791607569770570048, + 256 => -4839982369050771366, + 257 => -7326197626644746063, + 258 => -5760564212305582148, + 259 => 8245851483814498739, + 260 => -1261608103078589172, + 261 => 6872989402933107904, + 262 => 6926902352662665902, + 263 => 375124288680082211, + 264 => 3086545633031909538, + 265 => -6386804902164786029, + 266 => -1242790247806959997, + 267 => -1681430887095756027, + 268 => 5137372031839899489, + 269 => 2754788085284731462, + 270 => 6325822581971560136, + 271 => -8444821628536905566, + 272 => 2475558550482960736, + 273 => 6516139044969237568, + 274 => 6065815787485755018, + 275 => -2337634903387833087, + 276 => -6565883552260127024, + 277 => 9062653444256330533, + 278 => 4131468415902220, + 279 => -2804413712969716005, + 280 => 2317396077435523547, + 281 => -4970445540823094516, + 282 => 6420315594566913890, + 283 => -5922403123810491315, + 284 => -2808452863210499590, + 285 => 617483705407310346, + 286 => -6228542687770337922, + 287 => -1113468420487711679, + 288 => 8828681624504014775, + 289 => 6287274941865377114, + 290 => 5117868422945902333, + 291 => 1287551252614211749, + 292 => -1173498864336099974, + 293 => 5036837401203653996, + 294 => -2606254505571119214, + 295 => 3423852390119064549, + 296 => -9000591993750676812, + 297 => -8867631436364331574, + 298 => 6767524122168251427, + 299 => 162839175744794974, + 300 => -528555657111943786, + 301 => 2101582834726902697, + 302 => -317338495447985567, + 303 => -5648554254600403004, + 304 => 5564803131766712968, + 305 => -5252930376543610873, + 306 => 56271831026699195, + 307 => 8844442151310258591, + 308 => -1230301930879619982, + 309 => -6256187407793446292, + 310 => 4807718328804520520, + 311 => -5863940751946617339, + 312 => 6905938723205835745, + 313 => 4075335344864414281, + 314 => 3433531159208347315, + 315 => -2069840850591842763, + 316 => 7516036388331324446, + 317 => -2592397801079222232, + 318 => -8126100301504316342, + 319 => -7273022652949339827, + 320 => 7338189214894710364, + 321 => -9049129361743244256, + 322 => -569994482749250953, + 323 => 1999871819672998377, + 324 => -6983736397764704713, + 325 => -3071713744516734676, + 326 => -8071837264363519337, + 327 => 748694073946532348, + 328 => -3330632703556046290, + 329 => -1124594114902335244, + 330 => 2526761214268222568, + 331 => -1657220373902169273, + 332 => 371555305382119287, + 333 => -6368460380663182397, + 334 => 5727708374322006369, + 335 => 3383625716635606776, + 336 => 1490509743458220363, + 337 => -5823012005238396473, + 338 => 2657402502686094353, + 339 => 2523072086880676074, + 340 => -5212150126378343972, + 341 => 3263546208638625941, + 342 => -8842197938699360653, + 343 => 6374843986142087000, + 344 => 4220080406234818700, + 345 => -230832620073276369, + 346 => 6840381043077099619, + 347 => -1613588878580426717, + 348 => 3390573976942207403, + 349 => 430050069716772959, + 350 => 4962800447006999936, + 351 => 2185947515463616467, + 352 => 4271389234446298896, + 353 => -5340519306352117744, + 354 => 1197203261499495306, + 355 => 6677131389043771525, + 356 => 5546711611730970947, + 357 => -6529594906300554712, + 358 => -5989672402410720514, + 359 => 1153906435455000794, + 360 => -6056925494745450161, + 361 => 4199404349532119493, + 362 => 6557837025617915863, + 363 => 2556671403775761341, + 364 => -4544597408257187481, + 365 => 814880520407626678, + 366 => -5852348228132151619, + 367 => 6492249149631356053, + 368 => -3177829576285382316, + 369 => 4864154138545570939, + 370 => -8677430544928980841, + 371 => 8749511087731377965, + 372 => -9152552649319357740, + 373 => 402896885114503720, + 374 => -7491531018035586066, + 375 => 6355574295691978853, + 376 => -2704974177237563067, + 377 => 1165814196029775407, + 378 => 3208728433494425336, + 379 => 1429392515143905195, + 380 => 2380441736978229060, + 381 => -6658299069287454659, + 382 => 4109416891616055006, + 383 => -5146082782977310060, + 384 => -1278045846500555482, + 385 => -4765004337146065901, + 386 => -4262098568510576231, + 387 => 1086271076349384072, + 388 => 5650601861900182068, + 389 => -2632384338904542913, + 390 => 6381088846802079525, + 391 => 5513341014011794810, + 392 => 3835165564590331379, + 393 => -6274557285119588118, + 394 => -30989483748122322, + 395 => -7017532806115885258, + 396 => 4383771638185842327, + 397 => 1544994207802977422, + 398 => 6628347564412562227, + 399 => 4675575756843593136, + 400 => 6877298263631656980, + 401 => 8188015606131763609, + 402 => -5798386943811896584, + 403 => -6773161803381332958, + 404 => -3661002970975771146, + 405 => 5643851515130170925, + 406 => -6200679549515097687, + 407 => -2538924580828788363, + 408 => 6125484710344506788, + 409 => 4417758651294828199, + 410 => -529498194253919357, + 411 => -6349934711223662455, + 412 => -4133451028214498258, + 413 => 2659634268627517050, + 414 => -458638004142023708, + 415 => 3600950078580554951, + 416 => -4701618839941594073, + 417 => 607344099330032742, + 418 => -2851435838091702918, + 419 => -1485062284045911889, + 420 => 1805718222250101604, + 421 => -3086433846926675995, + 422 => 3055925737213207767, + 423 => 7918979740159439390, + 424 => 2899418100314977091, + 425 => -5832127953693127691, + 426 => 1843869831041188589, + 427 => -5473289788120622366, + 428 => -8201178903628152904, + 429 => -2115228561554159419, + 430 => -389224390707379122, + 431 => -9093559932117923740, + 432 => 5415491869480049272, + 433 => -8834861133961889021, + 434 => -6614115603878181597, + 435 => -3507458754926709108, + 436 => -7229539372363003824, + 437 => -6527827874523834853, + 438 => 3202286537820120427, + 439 => 1295397612851020484, + 440 => -5043151425327244028, + 441 => 5615542153522392944, + 442 => -3302134258426565077, + 443 => 8459571853036894401, + 444 => 8208349094629138494, + 445 => 2108436006859028411, + 446 => -6092720355006722234, + 447 => 1968981523666278118, + 448 => -101963916550265467, + 449 => -3948811310562517646, + 450 => 3636703248408361268, + 451 => -1552158689729703948, + 452 => 344569421890938331, + 453 => 3153426948205039434, + 454 => 3831443709948604790, + 455 => -7482874978444912533, + 456 => -8980635650087970291, + 457 => -7420978390768120119, + 458 => -3805183150388771142, + 459 => -8592206455135356838, + 460 => -4169869898673179931, + 461 => 6663497159539159252, + 462 => 6865991479013201996, + 463 => -3658613259597233946, + 464 => -2486044299508991132, + 465 => 176634638428440638, + 466 => 3417847617901708310, + 467 => -3412736106075467201, + 468 => -47475402023430678, + 469 => -1844793694882286512, + 470 => -5222923010569976067, + 471 => -4436398227243152460, + 472 => 547747285585891162, + 473 => -6323683244389026449, + 474 => -4708566515748500503, + 475 => 5643562417717223350, + 476 => -5619618775527313253, + 477 => 8396858592130943772, + 478 => -81980553927762199, + 479 => 6409158638386858241, + 480 => 868451702856774451, + 481 => -7515541903071356571, + 482 => 2775746172925619768, + 483 => -3959430666688528952, + 484 => 6107868953750438655, + 485 => -2810795034820816925, + 486 => 4076844493593644827, + 487 => 8773464140668878334, + 488 => 665563913863651145, + 489 => 1758865298764529711, + 490 => 7470695950012076537, + 491 => -6427052574999633807, + 492 => -8853017404388704334, + 493 => -67654987091025103, + 494 => -5616973146317754880, + 495 => -6672515566919359409, + 496 => 415674102292236891, + 497 => -7370965881417330052, + 498 => 2496977896463373137, + 499 => 4815108696942023418, + 500 => 1448947258530766570, + 501 => -3659170523175704243, + 502 => -4051068912774759681, + 503 => -7076448156120582778, + 504 => -339502045327716956, + 505 => 7887873460024142462, + 506 => -5011349799595590590, + 507 => 4632660736855694530, + 508 => -8042521843475302648, + 509 => -93960121909642080, + 510 => -859279068895495769, + 511 => 1436502566364554793, + 512 => 4661650455009769138, + 513 => -1367319235255133031, + 514 => -2724699325313542291, + 515 => 4652447082911812293, + 516 => -5278219026866400834, + 517 => 6442301838607647893, + 518 => -9032634577889300878, + 519 => -2365413696709399012, + 520 => 291255837956078423, + 521 => -4324961647351857391, + 522 => 8366539432314551964, + 523 => -3618586235506258118, + 524 => -4088991976812578600, + 525 => 8866009886057376505, + 526 => -1164675704473499595, + 527 => -733828172710265947, + 528 => 3721170446183142566, + 529 => -7542197863491450437, + 530 => -1712621052183742250, + 531 => -3565518457683389659, + 532 => -3867814354031431969, + 533 => 1071054827462757220, + 534 => -5780308877220069255, + 535 => 6501231003855506209, + 536 => -8299609080785849722, + 537 => -2266799782662095574, + 538 => 1254437552556397638, + 539 => 7529094578579873888, + 540 => 9216111357151639783, + 541 => 4290842053926601137, + 542 => -408097871172205509, + 543 => -6098158652164334622, + 544 => 4560615506624619824, + 545 => 1441946062740964614, + 546 => -2356494385649000061, + 547 => -6393994505290781007, + 548 => 6268941505017737601, + 549 => -7026752638854795496, + 550 => -9007488950282488746, + 551 => 544823521126189784, + 552 => 5034374304218028947, + 553 => 4852392840271973608, + 554 => -7354838055116483992, + 555 => 4757982758220186480, + 556 => -3945886949840132900, + 557 => -7887258696170849338, + 558 => 6557666489885352857, + 559 => -4090135982574429680, + 560 => -2209417856246080539, + 561 => -7575371593857187593, + 562 => -8090177762677346748, + 563 => 2189297164944265391, + 564 => -5305673121306276106, + 565 => 8149527980046285739, + 566 => 9072803674881942311, + 567 => -3727781672496714946, + 568 => -4400190333335169546, + 569 => 4929789674243306992, + 570 => 6743618993461016585, + 571 => 5731315688971662726, + 572 => -3471064556019332724, + 573 => -7174609127936588654, + 574 => 3722867198854092467, + 575 => 1606440016596383813, + 576 => -2281489864617621195, + 577 => -1307142118175400213, + 578 => -8547196223739630571, + 579 => 3391767703832409341, + 580 => 8799898891798389498, + 581 => -1438033249762020363, + 582 => -5205883837927928287, + 583 => -354294276179153804, + 584 => 6548274220194567972, + 585 => -395094657710054060, + 586 => -223258724280665764, + 587 => -4141570294239017131, + 588 => -7018185330318606895, + 589 => -4745192051522803483, + 590 => -3035937451831963377, + 591 => -7320364774498020915, + 592 => 5203488311385588525, + 593 => 3921673848392800763, + 594 => 8352479268375121300, + 595 => -8628352876367206996, + 596 => 4723056794586165779, + 597 => -2817447054226988700, + 598 => 715197134215905262, + 599 => -7309324249306968779, + 600 => -7734152778173858377, + 601 => -5878373178705856204, + 602 => 5077302071396544677, + 603 => 4384550154340128969, + 604 => -2193553863697783876, + 605 => 6450438775605670536, + 606 => -6191431598372742659, + 607 => 6785579812047917231, + 608 => -7824530323089277441, + 609 => -8687366427736726977, + 610 => -9051816987087087647, + 611 => -2898779336555377483, + 612 => -8920792961980561914, + 613 => -1183810620103972743, + 614 => -9012986667578064937, + 615 => 5845271287684574247, + 616 => 89900067894800102, + 617 => 723451886389806228, + 618 => 4227548194166174723, + 619 => 35005151054137666, + 620 => 8157739297860697369, + 621 => -1333108648502887119, + 622 => 50337023990632811, + 623 => 8495968937583214559, + 624 => -3118644616312363936, + 625 => -339081784497171008, + 626 => -3883112634596268413, + 627 => 7371711793659079330, + 628 => 1131683747671733265, + 629 => 2829379398359422777, + 630 => -2233697304072295485, + 631 => 8343047786265395518, + 632 => -8943122549423061868, + 633 => -1499216027200102431, + 634 => -8227784499111018668, + 635 => 2069004878811864194, + 636 => -4801279027199694691, + 637 => 2591156145230303168, + 638 => -8229262055382287264, + 639 => -955232685823124917, + 640 => -7128627162717136214, + 641 => 3600549156336082400, + 642 => 4148832535826281234, + 643 => 6065767451699974502, + 644 => -5138657576901317318, + 645 => 3591402789813511717, + 646 => 9173864694539222259, + 647 => 7218260271166567449, + 648 => -8312738093967053513, + 649 => 7395441930341865752, + 650 => 4182669345947933511, + 651 => -5570822222802602811, + 652 => -8695090160166514763, + 653 => 3554391762483220057, + 654 => 7203892294365329317, + 655 => -1245686942434426689, + 656 => -9154373059619059776, + 657 => 8061423983278721267, + 658 => 274618224932948691, + 659 => 7238797143773480424, + 660 => 3042417581470073057, + 661 => -7470067382621240133, + 662 => -7155435792581656619, + 663 => -6750533560516847929, + 664 => -9100571687673475828, + 665 => 2172377672402610172, + 666 => 4607775954709915104, + 667 => 2633564710574450825, + 668 => -440466839734544329, + 669 => -1833683717353879571, + 670 => -3367050441671906983, + 671 => -7187391084983878601, + 672 => 6819949303744019304, + 673 => -7636595526428866807, + 674 => 1603598337796156446, + 675 => -2148110433211081121, + 676 => -4181764820584200478, + 677 => -226482004269571418, + 678 => -5092083714833001363, + 679 => -1586127894523091543, + 680 => -6940048956739022178, + 681 => 4325779775579872014, + 682 => -4493697402575059386, + 683 => -6942573353588993724, + 684 => -2369398773228867259, + 685 => 6523732807512685365, + 686 => -3914331226447729250, + 687 => -6312991331644753137, + 688 => 2463089075978487850, + 689 => 5942038886592587187, + 690 => -2736747757605557932, + 691 => -2604679761750363227, + 692 => -5236914441531458981, + 693 => -9129970263201345311, + 694 => -7841113372851620154, + 695 => 5110232547017368817, + 696 => 2963518158044809045, + 697 => -7594651228614914597, + 698 => 5965113606436673766, + 699 => 3754948836429818415, + 700 => -4719608804947903215, + 701 => 8640677616684078379, + 702 => 6967424873872529129, + 703 => -6089669733481258704, + 704 => 5599478864787022443, + 705 => 8314990936231051787, + 706 => 6311810127450425579, + 707 => 5249399024176335189, + 708 => 103842905214310526, + 709 => 8152692012953776669, + 710 => 5134884029603665767, + 711 => -5903272824635797618, + 712 => 2527592953365210976, + 713 => -6670772109936340503, + 714 => -8079363786114209212, + 715 => 202683570973492246, + 716 => -4780925294118263010, + 717 => 7791294875101563043, + 718 => -2434181289575299809, + 719 => 3096247300133031563, + 720 => -3382291029157281135, + 721 => -1633139325931102067, + 722 => 4055022258114515477, + 723 => 5184632271497691625, + 724 => 8041543039285260087, + 725 => 9169450631130174018, + 726 => -5994134443650836497, + 727 => 5377552931080754290, + 728 => 6781094978221293695, + 729 => -3058245258601876172, + 730 => 8647836490648561448, + 731 => 9204238357764121516, + 732 => 4639550637796145800, + 733 => -4036695914699606803, + 734 => -6586853967081591960, + 735 => 2217555294189448604, + 736 => 2462524099274386779, + 737 => 7038972471117135538, + 738 => -1258166079479930140, + 739 => 8154839192981506987, + 740 => 1378649999525075752, + 741 => 2265070541255812462, + 742 => 6660639262639355689, + 743 => 8278390549334049418, + 744 => 1398804134780334239, + 745 => 3951848085679927098, + 746 => -4860732352076459395, + 747 => 1752860345255544942, + 748 => 3518565518062206342, + 749 => 44635178712367668, + 750 => 8819357152559972510, + 751 => 4324473660628336159, + 752 => -8011743185024178590, + 753 => -8996407027677781508, + 754 => -711486139381222093, + 755 => -6215560460381736449, + 756 => 4859311728140826134, + 757 => -4154412386794590448, + 758 => -2187493165082612022, + 759 => 2464743043626754766, + 760 => -1278668725642229846, + 761 => 7535747723854303750, + 762 => -4599413124745507887, + 763 => -8384367724651183264, + 764 => -4768056484040511931, + 765 => 3903649810882634856, + 766 => -9114048027883989026, + 767 => -2320424958042444979, + 768 => -7915143986980574937, + 769 => -5990724003776925258, + 770 => 6400115942346890800, + 771 => -8457138652158711764, + 772 => -8401655182225845757, + 773 => 6750212895511422770, + 774 => 9090967212745014082, + 775 => -5414472999461007184, + 776 => 8429990020782938922, + 777 => 97664500888661427, + 778 => -1442483336869955176, + 779 => 6008593087619083741, + 780 => -1480697624698781186, + 781 => -4348967702172984534, + 782 => 3177361827679702377, + 783 => -6900631919905874181, + 784 => 6021444853957245659, + 785 => -7227850878153061194, + 786 => -1195874374241769354, + 787 => 6661093487619994495, + 788 => 4251053954778494552, + 789 => 4304300754415869912, + 790 => 8945951823030436209, + 791 => -2189536974954360033, + 792 => 4660601550115800006, + 793 => -8705718504226603426, + 794 => -30314380125555180, + 795 => -2124188600653105723, + 796 => -8988678114752811490, + 797 => -4661299667794090495, + 798 => -3716593098366518200, + 799 => -6963820656735835233, + 800 => 8306975118722797170, + 801 => -3180537092880844233, + 802 => 5818178421901066092, + 803 => 3466113066776082895, + 804 => 3236503107074434860, + 805 => 3692066395517072305, + 806 => -3321089923525302759, + 807 => 6149315052487044862, + 808 => -2314051100246146996, + 809 => 6965404851869135431, + 810 => -2796843551604500034, + 811 => -3337532210543781996, + 812 => -5075807979523229029, + 813 => -3013425084612083573, + 814 => 7060657560684690775, + 815 => 6094913806874935224, + 816 => -6632829607064036582, + 817 => -388777867445040277, + 818 => 194273700252962419, + 819 => -4637773599759175080, + 820 => 5658689583201756908, + 821 => 5927968034409883711, + 822 => -1926945266711223242, + 823 => 887124368422698254, + 824 => 7902874002962332365, + 825 => -5190573611684043966, + 826 => 6390068748505010312, + 827 => -8483588010833879249, + 828 => 7373119916255358592, + 829 => -8133440636763316932, + 830 => 7816690008378435750, + 831 => 6258129100564864529, + 832 => 84860055309189315, + 833 => 104217346528256607, + 834 => 1784411862595038508, + 835 => -6692758882762963920, + 836 => -392579159751869227, + 837 => -5440273793689547370, + 838 => 2211457723441433664, + 839 => 4677479183441445747, + 840 => -7237144321548105758, + 841 => 2067932511574341308, + 842 => -1840461952158254531, + 843 => -7275904528247510322, + 844 => -1017180139088664090, + 845 => -4593128485273960271, + 846 => -4362678013637898305, + 847 => 652729615873215153, + 848 => -8937166158943239239, + 849 => 7772201589069106918, + 850 => -4220901327248431319, + 851 => 5567144741691071653, + 852 => -4866863954385131954, + 853 => -3828628549119377123, + 854 => -8105422276414743310, + 855 => 6946066927781308917, + 856 => 2149454852811638966, + 857 => 3543049813335419073, + 858 => -5644203139571161234, + 859 => -230830575866440960, + 860 => -5166044678871911698, + 861 => -2426272925756130828, + 862 => -8733403867598818577, + 863 => -5393506827649123582, + 864 => -1905034835691728003, + 865 => 4931641918014241470, + 866 => 7399348859035757945, + 867 => 647810499281296411, + 868 => -1182376879388191632, + 869 => -5692663281107713947, + 870 => 115196835673478044, + 871 => -2826937891202652367, + 872 => 5683618595113999722, + 873 => -393518798616393564, + 874 => 2878586433222280062, + 875 => -3463835156768550086, + 876 => 3879474712065936314, + 877 => -4231953664287818315, + 878 => 5019011566836889768, + 879 => -4418878221582318478, + 880 => -3187384851282319501, + 881 => -6384937752772349038, + 882 => 2684172126043671085, + 883 => 124077701149568470, + 884 => -5041375737715627525, + 885 => -4637883959022440123, + 886 => -4637577816967663592, + 887 => -8371926557363522626, + 888 => 1269560195920399142, + 889 => -2774810987641595566, + 890 => -1613913261307275017, + 891 => 2651044762923498036, + 892 => -268379860966422832, + 893 => 7938127533340238065, + 894 => 9053830165287525824, + 895 => -7684035202762092701, + 896 => 6640066852353009558, + 897 => 3184916088507222283, + 898 => -7186118253069868344, + 899 => -8547548796601846206, + 900 => -6391111387808661828, + 901 => -6136185268635580285, + 902 => -300759434468849360, + 903 => 5294887371366644926, + 904 => -4582769374150405627, + 905 => 8090717093935427144, + 906 => -1670682816307185016, + 907 => 7056854629142196937, + 908 => -2910759880910102163, + 909 => 7361700069409734649, + 910 => -1690060789141443371, + 911 => -6683547544626397307, + 912 => -1019930487528113280, + 913 => 571575931060051486, + 914 => -4560281692828658072, + 915 => -7493981612348008717, + 916 => -878591107647456023, + 917 => 166198440251266051, + 918 => 665561950732786268, + 919 => 6200807398302711915, + 920 => -5580524710909594073, + 921 => 1669940693832753870, + 922 => 3170321178207205150, + 923 => 2998803801750296321, + 924 => 3126132563735407603, + 925 => 1763410990965719932, + 926 => 8011693403829410701, + 927 => -30338996460631921, + 928 => 3813039297977403180, + 929 => 7123611900334014372, + 930 => -6244239133370569777, + 931 => -2165861727345346781, + 932 => -9052223422370358053, + 933 => -7637648213028218507, + 934 => 8258740904849073848, + 935 => 2358340773665012611, + 936 => 2198343093499517862, + 937 => 757533622598785626, + 938 => -7110288085302027552, + 939 => -2603817203181154886, + 940 => -1344683278628798247, + 941 => 1328068394087933560, + 942 => -109678276064482657, + 943 => 5778692018223432558, + 944 => -5245768555498035311, + 945 => 5037331728004575260, + 946 => 7664194644963194966, + 947 => -2203796763742957964, + 948 => 2999841328490736427, + 949 => 8719499224375008549, + 950 => 7419402210670310694, + 951 => 1135029321797470055, + 952 => 2452413875197756640, + 953 => 3210502048366657435, + 954 => -3759195895003919766, + 955 => 7814835862455467029, + 956 => 257897893392878470, + 957 => -6396364988658192928, + 958 => -1306348054014052655, + 959 => 6066172523095173574, + 960 => 1521935404744234458, + 961 => 1784455976467862558, + 962 => 78433478117057585, + 963 => 5679820990451387189, + 964 => -3468334703938491107, + 965 => -2581454374397003300, + 966 => 1615438926725040316, + 967 => -5726442198683361780, + 968 => 85076344323286000, + 969 => -5112775195587054468, + 970 => -150307727175614379, + 971 => 5532355602662544800, + 972 => 7630967255623092283, + 973 => 6031601808396254731, + 974 => 2589259806720179012, + 975 => -2443438982692086376, + 976 => -5323633515992320591, + 977 => 5619225783179764001, + 978 => 6278136266045371772, + 979 => 1080635057999987543, + 980 => 2002009050098103958, + 981 => 6944494982368775038, + 982 => 8127064054714857053, + 983 => -9148606733100273122, + 984 => 3909782287020388198, + 985 => -1194357009610133253, + 986 => -8084026951783919511, + 987 => -1137276877760546631, + 988 => 2074327463971599953, + 989 => -9047662919993467959, + 990 => 9096773588823070330, + 991 => -5025192952012469599, + 992 => 1074614018506534433, + 993 => 6962038332185431193, + 994 => -5699727967137895044, + 995 => -3285423490225126731, + 996 => -901653703310797881, + 997 => -4554697698178367078, + 998 => 7855871831302852481, + 999 => 853126557890749925, +); + +$rng = new \RNG\XorShift128Plus(SEED); +foreach ($result as $ret) { + $rng_next = $rng->next64(); + if ($ret !== $rng_next) { + die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); + } +} + +die('OK, Result is consistent.'); +?> +--EXPECT-- +OK, Result is consistent. diff --git a/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt b/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt new file mode 100644 index 0000000000000..2cd9d45c8f736 --- /dev/null +++ b/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test class: XorShift128Plus: unexcepted __unserialize(). +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Exception: Incomplete or ill-formed serialization data in %s:%i +Stack trace: +#0 [internal function]: %s->__unserialize(Array) +#1 %s(%i): unserialize('%s') +#2 {main} + thrown in %s on line %i From 6834426452b151c36e4d1e292ad997d6bcf139ae Mon Sep 17 00:00:00 2001 From: zeriyoshi Date: Mon, 25 Jan 2021 09:28:24 +0900 Subject: [PATCH 2/2] RFC 1.3 --- ...flectionExtension_getClassNames_basic.phpt | 16 +- ext/standard/basic_functions.stub.php | 9 +- ext/standard/basic_functions_arginfo.h | 39 +- ext/standard/config.m4 | 2 +- ext/standard/config.w32 | 3 +- ext/standard/php_rng.h | 1 - ext/standard/rng.c | 105 +- ext/standard/rng_mt19937.c | 7 +- ext/standard/rng_mt19937.stub.php | 3 +- ext/standard/rng_mt19937_arginfo.h | 2 +- ext/standard/{rng_osrng.c => rng_os.c} | 35 +- ext/standard/{rng_osrng.h => rng_os.h} | 8 +- .../{rng_osrng.stub.php => rng_os.stub.php} | 3 +- ext/standard/rng_os_arginfo.h | 18 + ext/standard/rng_osrng_arginfo.h | 18 - ext/standard/rng_rng64interface.stub.php | 11 - ext/standard/rng_rng64interface_arginfo.h | 13 - ext/standard/rng_rnginterface.stub.php | 1 + ext/standard/rng_rnginterface_arginfo.h | 5 +- ext/standard/rng_xorshift128plus.c | 7 +- ext/standard/rng_xorshift128plus.stub.php | 3 +- ext/standard/rng_xorshift128plus_arginfo.h | 2 +- ext/standard/tests/rng/_rng_classes.inc | 2 +- ext/standard/tests/rng/class_clone.phpt | 8 +- ext/standard/tests/rng/class_inheritance.phpt | 3 - ext/standard/tests/rng/class_serialize.phpt | 18 +- .../tests/rng/class_serialize_64.phpt | 18 +- ext/standard/tests/rng/class_userland.phpt | 24 +- .../tests/rng/class_userland_extend.phpt | 33 - .../tests/rng/function_array_rand.phpt | 10 +- .../tests/rng/function_rng_bytes.phpt | 6 +- .../tests/rng/function_rng_bytes_string.phpt | 11 +- ...on_rng_rand.phpt => function_rng_int.phpt} | 12 +- ..._rand_64.phpt => function_rng_int_64.phpt} | 10 +- ext/standard/tests/rng/function_shuffle.phpt | 6 +- .../tests/rng/function_str_shuffle.phpt | 4 +- ext/standard/tests/rng/method_next.phpt | 2 +- ext/standard/tests/rng/method_next_64.phpt | 8 +- .../tests/rng/mt19937_consistency.phpt | 26 +- ext/standard/tests/rng/mt19937_result.phpt | 4 +- ext/standard/tests/rng/mt19937_result_64.phpt | 2004 ++++++++--------- .../rng/mt19937_unserialize_unexcepted.phpt | 2 +- .../tests/rng/xorshift128plus_result.phpt | 4 +- .../tests/rng/xorshift128plus_result_64.phpt | 2004 ++++++++--------- ...orshift128plus_unserialize_unexcepted.phpt | 2 +- 45 files changed, 2264 insertions(+), 2268 deletions(-) rename ext/standard/{rng_osrng.c => rng_os.c} (70%) rename ext/standard/{rng_osrng.h => rng_os.h} (89%) rename ext/standard/{rng_osrng.stub.php => rng_os.stub.php} (66%) create mode 100644 ext/standard/rng_os_arginfo.h delete mode 100644 ext/standard/rng_osrng_arginfo.h delete mode 100644 ext/standard/rng_rng64interface.stub.php delete mode 100644 ext/standard/rng_rng64interface_arginfo.h delete mode 100644 ext/standard/tests/rng/class_userland_extend.phpt rename ext/standard/tests/rng/{function_rng_rand.phpt => function_rng_int.phpt} (54%) rename ext/standard/tests/rng/{function_rng_rand_64.phpt => function_rng_int_64.phpt} (64%) diff --git a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt index a8d4cd64a2922..fd472b28f44d6 100644 --- a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt +++ b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt @@ -8,23 +8,21 @@ $standard = new ReflectionExtension('standard'); var_dump($standard->getClassNames()); ?> --EXPECTF-- -array(9) { +array(8) { [0]=> %s(22) "__PHP_Incomplete_Class" [1]=> - %s(15) "php_user_filter" + %s(14) "AssertionError" [2]=> - %s(9) "Directory" + %s(15) "php_user_filter" [3]=> - %s(14) "AssertionError" + %s(9) "Directory" [4]=> %s(16) "RNG\RNGInterface" [5]=> - %s(18) "RNG\RNG64Interface" - [6]=> %s(19) "RNG\XorShift128Plus" - [7]=> + [6]=> %s(11) "RNG\MT19937" - [8]=> - %s(9) "RNG\OSRNG" + [7]=> + %s(6) "RNG\OS" } diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index bbb8545015bb4..ed57327064ea1 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1205,10 +1205,15 @@ function random_int(int $min, int $max): int {} /* rng.c */ -function rng_rand(RNG\RNGInterface $rng, int $min = UNKNOWN, int $max = UNKNOWN): int {} - function rng_bytes(RNG\RNGInterface $rng, int $length): string {} +function rng_int(RNG\RNGInterface $rng, int $min, int $max): int {} + +function rng_next(RNG\RNGInterface $rng, bool $unsigned = true): int {} + +/** @throws ValueError */ +function rng_next64(RNG\RNGInterface $rng, bool $unsigned = true): int {} + /* soundex.c */ function soundex(string $string): string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index a61d6b1b82642..708c94a0cb2d6 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 23c263defa042155631bec5fcb5282e4cd1e88a7 */ + * Stub hash: f84bdc5decf171d559698bc9b40b0582ea57b084 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -186,7 +186,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_range, 0, 2, IS_ARRAY, 0) ZEND_ARG_TYPE_MASK(0, step, MAY_BE_LONG|MAY_BE_DOUBLE, "1") ZEND_END_ARG_INFO() -#define arginfo_shuffle arginfo_natsort +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shuffle, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(1, array, IS_ARRAY, 0) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, rng, RNG\\RNGInterface, 1, "null") +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_pop, 0, 1, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(1, array, IS_ARRAY, 0) @@ -316,6 +319,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_array_rand, 0, 1, MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY) ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num, IS_LONG, 0, "1") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, rng, RNG\\RNGInterface, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_array_sum, 0, 1, MAY_BE_LONG|MAY_BE_DOUBLE) @@ -1066,7 +1070,10 @@ ZEND_END_ARG_INFO() #define arginfo_str_rot13 arginfo_base64_encode -#define arginfo_str_shuffle arginfo_base64_encode +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_str_shuffle, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, rng, RNG\\RNGInterface, 1, "null") +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_str_word_count, 0, 1, MAY_BE_ARRAY|MAY_BE_LONG) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) @@ -1838,6 +1845,24 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_random_int, 0, 2, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, max, IS_LONG, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rng_bytes, 0, 2, IS_STRING, 0) + ZEND_ARG_OBJ_INFO(0, rng, RNG\\RNGInterface, 0) + ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rng_int, 0, 3, IS_LONG, 0) + ZEND_ARG_OBJ_INFO(0, rng, RNG\\RNGInterface, 0) + ZEND_ARG_TYPE_INFO(0, min, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, max, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rng_next, 0, 1, IS_LONG, 0) + ZEND_ARG_OBJ_INFO(0, rng, RNG\\RNGInterface, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unsigned, _IS_BOOL, 0, "true") +ZEND_END_ARG_INFO() + +#define arginfo_rng_next64 arginfo_rng_next + #define arginfo_soundex arginfo_base64_encode ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_stream_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) @@ -2730,6 +2755,10 @@ ZEND_FUNCTION(mt_rand); ZEND_FUNCTION(mt_getrandmax); ZEND_FUNCTION(random_bytes); ZEND_FUNCTION(random_int); +ZEND_FUNCTION(rng_bytes); +ZEND_FUNCTION(rng_int); +ZEND_FUNCTION(rng_next); +ZEND_FUNCTION(rng_next64); ZEND_FUNCTION(soundex); ZEND_FUNCTION(stream_select); ZEND_FUNCTION(stream_context_create); @@ -3372,6 +3401,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FALIAS(getrandmax, mt_getrandmax, arginfo_getrandmax) ZEND_FE(random_bytes, arginfo_random_bytes) ZEND_FE(random_int, arginfo_random_int) + ZEND_FE(rng_bytes, arginfo_rng_bytes) + ZEND_FE(rng_int, arginfo_rng_int) + ZEND_FE(rng_next, arginfo_rng_next) + ZEND_FE(rng_next64, arginfo_rng_next64) ZEND_FE(soundex, arginfo_soundex) ZEND_FE(stream_select, arginfo_stream_select) ZEND_FE(stream_context_create, arginfo_stream_context_create) diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index bc6c968b29239..5994374228076 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -429,7 +429,7 @@ fi dnl dnl rng dnl -PHP_ADD_SOURCES(PHP_EXT_DIR(standard), rng_xorshift128plus.c rng_mt19937.c rng_osrng.c) +PHP_ADD_SOURCES(PHP_EXT_DIR(standard), rng_xorshift128plus.c rng_mt19937.c rng_os.c) dnl dnl Setup extension sources diff --git a/ext/standard/config.w32 b/ext/standard/config.w32 index 289e8b903d617..fe78c0fbbedd2 100644 --- a/ext/standard/config.w32 +++ b/ext/standard/config.w32 @@ -35,7 +35,8 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \ url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \ php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \ user_filters.c uuencode.c filters.c proc_open.c password.c \ - streamsfuncs.c http.c flock_compat.c random.c hrtime.c rng.c rng_mt19937.c rng_osrng.c rng_xorshift128plus.c", false /* never shared */, + streamsfuncs.c http.c flock_compat.c random.c hrtime.c \ + rng.c rng_xorshift128plus.c rng_mt19937.c rng_os.c ", false /* never shared */, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); PHP_STANDARD = "yes"; ADD_MAKEFILE_FRAGMENT(); diff --git a/ext/standard/php_rng.h b/ext/standard/php_rng.h index d66dbedb2d0d1..933a7bf0691c8 100644 --- a/ext/standard/php_rng.h +++ b/ext/standard/php_rng.h @@ -20,7 +20,6 @@ #include "php.h" extern PHPAPI zend_class_entry *rng_ce_RNG_RNGInterface; -extern PHPAPI zend_class_entry *rng_ce_RNG_RNG64Interface; typedef struct _php_rng php_rng; typedef struct _php_rng { diff --git a/ext/standard/rng.c b/ext/standard/rng.c index 185b38d64242f..bad1615257782 100644 --- a/ext/standard/rng.c +++ b/ext/standard/rng.c @@ -20,14 +20,12 @@ #include "php_rng.h" #include "rng_rnginterface_arginfo.h" -#include "rng_rng64interface_arginfo.h" #include "rng_xorshift128plus.h" #include "rng_mt19937.h" -#include "rng_osrng.h" +#include "rng_os.h" PHPAPI zend_class_entry *rng_ce_RNG_RNGInterface; -PHPAPI zend_class_entry *rng_ce_RNG_RNG64Interface; PHPAPI php_rng* php_rng_initialize(uint32_t (*next)(php_rng*), uint64_t (*next64)(php_rng*)) { @@ -191,33 +189,6 @@ PHPAPI zend_long php_rng_range(zval *obj, zend_long min, zend_long max) return (zend_long) (rng_rand_range32(obj, umax) + min); } -PHP_FUNCTION(rng_rand) -{ - zval *zrng; - zend_long min, max; - - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_OBJECT_OF_CLASS(zrng, rng_ce_RNG_RNGInterface) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(min) - Z_PARAM_LONG(max) - ZEND_PARSE_PARAMETERS_END(); - - if (ZEND_NUM_ARGS() == 1) { - uint32_t result; - - php_rng_next(&result, zrng); - RETURN_LONG((zend_long) (result >> 1)); - } - - if (UNEXPECTED(max < min)) { - zend_argument_value_error(2, "must be greater than or equal to argument #1 ($min)"); - RETURN_THROWS(); - } - - RETURN_LONG(php_rng_range(zrng, min, max)); -} - PHP_FUNCTION(rng_bytes) { zval *zrng; @@ -254,20 +225,82 @@ PHP_FUNCTION(rng_bytes) } } +PHP_FUNCTION(rng_int) +{ + zval *zrng; + zend_long min, max; + + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(zrng, rng_ce_RNG_RNGInterface) + Z_PARAM_LONG(min) + Z_PARAM_LONG(max) + ZEND_PARSE_PARAMETERS_END(); + + if (min > max) { + zend_argument_value_error(1, "must be less than or equal to argument #2 ($max)"); + RETURN_THROWS(); + } + + RETURN_LONG(php_rng_range(zrng, min, max)); +} + +PHP_FUNCTION(rng_next) +{ + zval *zrng; + uint32_t retval; + bool is_unsigned = 1; + + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(zrng, rng_ce_RNG_RNGInterface) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(is_unsigned) + ZEND_PARSE_PARAMETERS_END(); + + php_rng_next(&retval, zrng); + + if (is_unsigned) { + retval = retval >> 1; + } + + RETURN_LONG((zend_long) retval); +} + +PHP_FUNCTION(rng_next64) +{ + zval *zrng; + uint64_t retval; + bool is_unsigned = 1; + + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(zrng, rng_ce_RNG_RNGInterface) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(is_unsigned) + ZEND_PARSE_PARAMETERS_END(); + +#if UINT32_MAX >= ZEND_ULONG_MAX + zend_value_error("Functions doesn't support 32 bit environment."); + RETURN_THROWS(); +#endif + + php_rng_next64(&retval, zrng); + + if (is_unsigned) { + retval = retval >> 1; + } + + RETURN_LONG((zend_long) retval); +} + PHP_MINIT_FUNCTION(rng) { - zend_class_entry ce_rng, ce_rng64; + zend_class_entry ce_rng; INIT_CLASS_ENTRY(ce_rng, RNG_NAMESPACE "RNGInterface", class_RNG_RNGInterface_methods); rng_ce_RNG_RNGInterface = zend_register_internal_interface(&ce_rng); - INIT_CLASS_ENTRY(ce_rng64, RNG_NAMESPACE "RNG64Interface", class_RNG_RNG64Interface_methods); - rng_ce_RNG_RNG64Interface = zend_register_internal_interface(&ce_rng64); - zend_class_implements(rng_ce_RNG_RNG64Interface, 1, rng_ce_RNG_RNGInterface); - PHP_MINIT(rng_xorshift128plus)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(rng_mt19937)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(rng_osrng)(INIT_FUNC_ARGS_PASSTHRU); + PHP_MINIT(rng_os)(INIT_FUNC_ARGS_PASSTHRU); return SUCCESS; } diff --git a/ext/standard/rng_mt19937.c b/ext/standard/rng_mt19937.c index 798d6171f492f..ef5a317db7324 100644 --- a/ext/standard/rng_mt19937.c +++ b/ext/standard/rng_mt19937.c @@ -180,11 +180,6 @@ PHP_METHOD(RNG_MT19937, next64) ZEND_PARSE_PARAMETERS_NONE(); -#if UINT32_MAX >= ZEND_ULONG_MAX - zend_value_error("Method doesn't supported 32bit integer range."); - RETURN_THROWS(); -#endif - uint64_t result = rng->next(rng); result = (result << 32) | rng->next(rng); @@ -261,7 +256,7 @@ PHP_MINIT_FUNCTION(rng_mt19937) INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "MT19937", class_RNG_MT19937_methods); rng_ce_RNG_MT19937 = zend_register_internal_class(&ce); - zend_class_implements(rng_ce_RNG_MT19937, 1, rng_ce_RNG_RNG64Interface); + zend_class_implements(rng_ce_RNG_MT19937, 1, rng_ce_RNG_RNGInterface); rng_ce_RNG_MT19937->create_object = rng_object_new; memcpy(&MT19937_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); MT19937_handlers.offset = XtOffsetOf(php_rng, std); diff --git a/ext/standard/rng_mt19937.stub.php b/ext/standard/rng_mt19937.stub.php index 263f2390cfb6c..a101bf3597427 100644 --- a/ext/standard/rng_mt19937.stub.php +++ b/ext/standard/rng_mt19937.stub.php @@ -4,11 +4,10 @@ namespace RNG; -class MT19937 implements RNG64Interface +class MT19937 implements RNGInterface { public function __construct(int $seed) {} public function next(): int {} - /** @throws ValueError */ public function next64(): int {} public function __serialize(): array {} public function __unserialize(array $data): void {} diff --git a/ext/standard/rng_mt19937_arginfo.h b/ext/standard/rng_mt19937_arginfo.h index 87658d5282932..596f2fca19443 100644 --- a/ext/standard/rng_mt19937_arginfo.h +++ b/ext/standard/rng_mt19937_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c5bda9e0499794aa2294aa0ada1348b373bb46c7 */ + * Stub hash: 1729f4d864a1f9a8b07dd607128c1f6493c69f2c */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RNG_MT19937___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, seed, IS_LONG, 0) diff --git a/ext/standard/rng_osrng.c b/ext/standard/rng_os.c similarity index 70% rename from ext/standard/rng_osrng.c rename to ext/standard/rng_os.c index 13d336c88be1a..7d56bf35a7cc0 100644 --- a/ext/standard/rng_osrng.c +++ b/ext/standard/rng_os.c @@ -20,12 +20,12 @@ #include "zend_exceptions.h" -#include "rng_osrng.h" -#include "rng_osrng_arginfo.h" +#include "rng_os.h" +#include "rng_os_arginfo.h" -PHPAPI zend_class_entry *rng_ce_RNG_OSRNG; +PHPAPI zend_class_entry *rng_ce_RNG_OS; -static zend_object_handlers OSRNG_handlers; +static zend_object_handlers OS_handlers; static uint32_t next(php_rng *rng) { @@ -46,7 +46,7 @@ static zend_object *rng_object_new(zend_class_entry *ce) php_rng *rng = php_rng_initialize(next, next64); zend_object_std_init(&rng->std, ce); object_properties_init(&rng->std, ce); - rng->std.handlers = &OSRNG_handlers; + rng->std.handlers = &OS_handlers; return &rng->std; } @@ -57,7 +57,7 @@ static void free_object_storage(zend_object *object) zend_object_std_dtor(&rng->std); } -PHP_METHOD(RNG_OSRNG, next) +PHP_METHOD(RNG_OS, next) { php_rng *rng = Z_RNG_P(ZEND_THIS); @@ -66,31 +66,26 @@ PHP_METHOD(RNG_OSRNG, next) RETURN_LONG((zend_long) rng->next(rng)); } -PHP_METHOD(RNG_OSRNG, next64) +PHP_METHOD(RNG_OS, next64) { php_rng *rng = Z_RNG_P(ZEND_THIS); ZEND_PARSE_PARAMETERS_NONE(); -#if UINT32_MAX >= ZEND_ULONG_MAX - zend_value_error("Method doesn't supported 32bit integer range."); - RETURN_THROWS(); -#endif - RETURN_LONG((zend_long) rng->next64(rng)); } -PHP_MINIT_FUNCTION(rng_osrng) +PHP_MINIT_FUNCTION(rng_os) { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "OSRNG", class_RNG_OSRNG_methods); - rng_ce_RNG_OSRNG = zend_register_internal_class(&ce); - zend_class_implements(rng_ce_RNG_OSRNG, 1, rng_ce_RNG_RNG64Interface); - rng_ce_RNG_OSRNG->create_object = rng_object_new; - memcpy(&OSRNG_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - OSRNG_handlers.offset = XtOffsetOf(php_rng, std); - OSRNG_handlers.free_obj = free_object_storage; + INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "OS", class_RNG_OS_methods); + rng_ce_RNG_OS = zend_register_internal_class(&ce); + zend_class_implements(rng_ce_RNG_OS, 1, rng_ce_RNG_RNGInterface); + rng_ce_RNG_OS->create_object = rng_object_new; + memcpy(&OS_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + OS_handlers.offset = XtOffsetOf(php_rng, std); + OS_handlers.free_obj = free_object_storage; return SUCCESS; } diff --git a/ext/standard/rng_osrng.h b/ext/standard/rng_os.h similarity index 89% rename from ext/standard/rng_osrng.h rename to ext/standard/rng_os.h index a76c234cb1cce..e6d70e7779d24 100644 --- a/ext/standard/rng_osrng.h +++ b/ext/standard/rng_os.h @@ -13,14 +13,14 @@ | Authors: Go Kudo | +----------------------------------------------------------------------+ */ -#ifndef _RNG_OSRNG_H -#define _RNG_OSRNG_H +#ifndef _RNG_OS_H +#define _RNG_OS_H #include "php.h" #include "php_rng.h" -extern PHPAPI zend_class_entry *rng_ce_RNG_OSRNG; +extern PHPAPI zend_class_entry *rng_ce_RNG_OS; -PHP_MINIT_FUNCTION(rng_osrng); +PHP_MINIT_FUNCTION(rng_os); #endif diff --git a/ext/standard/rng_osrng.stub.php b/ext/standard/rng_os.stub.php similarity index 66% rename from ext/standard/rng_osrng.stub.php rename to ext/standard/rng_os.stub.php index d6561d97d94bb..9b90ffa0150d9 100644 --- a/ext/standard/rng_osrng.stub.php +++ b/ext/standard/rng_os.stub.php @@ -4,9 +4,8 @@ namespace RNG; -class OSRNG implements RNG64Interface +class OS implements RNGInterface { public function next(): int {} - /** @throws ValueError */ public function next64(): int {} } diff --git a/ext/standard/rng_os_arginfo.h b/ext/standard/rng_os_arginfo.h new file mode 100644 index 0000000000000..b781b9abf510f --- /dev/null +++ b/ext/standard/rng_os_arginfo.h @@ -0,0 +1,18 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 002ac5ccf036dde144c80a2a8d7950d56a50e7bc */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RNG_OS_next, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RNG_OS_next64 arginfo_class_RNG_OS_next + + +ZEND_METHOD(RNG_OS, next); +ZEND_METHOD(RNG_OS, next64); + + +static const zend_function_entry class_RNG_OS_methods[] = { + ZEND_ME(RNG_OS, next, arginfo_class_RNG_OS_next, ZEND_ACC_PUBLIC) + ZEND_ME(RNG_OS, next64, arginfo_class_RNG_OS_next64, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; diff --git a/ext/standard/rng_osrng_arginfo.h b/ext/standard/rng_osrng_arginfo.h deleted file mode 100644 index e7b7f358c13de..0000000000000 --- a/ext/standard/rng_osrng_arginfo.h +++ /dev/null @@ -1,18 +0,0 @@ -/* This is a generated file, edit the .stub.php file instead. - * Stub hash: be06b4ec73bcd250cd65377c2a5b23e74e74126b */ - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RNG_OSRNG_next, 0, 0, IS_LONG, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RNG_OSRNG_next64 arginfo_class_RNG_OSRNG_next - - -ZEND_METHOD(RNG_OSRNG, next); -ZEND_METHOD(RNG_OSRNG, next64); - - -static const zend_function_entry class_RNG_OSRNG_methods[] = { - ZEND_ME(RNG_OSRNG, next, arginfo_class_RNG_OSRNG_next, ZEND_ACC_PUBLIC) - ZEND_ME(RNG_OSRNG, next64, arginfo_class_RNG_OSRNG_next64, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; diff --git a/ext/standard/rng_rng64interface.stub.php b/ext/standard/rng_rng64interface.stub.php deleted file mode 100644 index 7e9b6d0a38a99..0000000000000 --- a/ext/standard/rng_rng64interface.stub.php +++ /dev/null @@ -1,11 +0,0 @@ -= ZEND_ULONG_MAX - zend_value_error("Method doesn't supported 32bit integer range."); - RETURN_THROWS(); -#endif - RETURN_LONG((zend_long) rng->next64(rng)); } @@ -195,7 +190,7 @@ PHP_MINIT_FUNCTION(rng_xorshift128plus) INIT_CLASS_ENTRY(ce, RNG_NAMESPACE "XorShift128Plus", class_RNG_XorShift128Plus_methods); rng_ce_RNG_XorShift128Plus = zend_register_internal_class(&ce); - zend_class_implements(rng_ce_RNG_XorShift128Plus, 1, rng_ce_RNG_RNG64Interface); + zend_class_implements(rng_ce_RNG_XorShift128Plus, 1, rng_ce_RNG_RNGInterface); rng_ce_RNG_XorShift128Plus->create_object = rng_object_new; memcpy(&XorShift128Plus_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); XorShift128Plus_handlers.offset = XtOffsetOf(php_rng, std); diff --git a/ext/standard/rng_xorshift128plus.stub.php b/ext/standard/rng_xorshift128plus.stub.php index fee1f1cadd97d..595e98874fb07 100644 --- a/ext/standard/rng_xorshift128plus.stub.php +++ b/ext/standard/rng_xorshift128plus.stub.php @@ -4,11 +4,10 @@ namespace RNG; -class XorShift128Plus implements RNG64Interface +class XorShift128Plus implements RNGInterface { public function __construct(int $seed) {} public function next(): int {} - /** @throws ValueError */ public function next64(): int {} public function __serialize(): array {} public function __unserialize(array $data): void {} diff --git a/ext/standard/rng_xorshift128plus_arginfo.h b/ext/standard/rng_xorshift128plus_arginfo.h index 9959e2c870c76..a12cb15bbbd67 100644 --- a/ext/standard/rng_xorshift128plus_arginfo.h +++ b/ext/standard/rng_xorshift128plus_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2a6e59481066545f803f93422c67ef124e4503eb */ + * Stub hash: 9d1a55b4da1703a844582adab7212f2213ec8dfb */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RNG_XorShift128Plus___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, seed, IS_LONG, 0) diff --git a/ext/standard/tests/rng/_rng_classes.inc b/ext/standard/tests/rng/_rng_classes.inc index d13657456caf5..501625ff60cc3 100644 --- a/ext/standard/tests/rng/_rng_classes.inc +++ b/ext/standard/tests/rng/_rng_classes.inc @@ -2,5 +2,5 @@ return [ '\\RNG\\XorShift128Plus' => true, '\\RNG\\MT19937' => true, - '\\RNG\\OSRNG' => false, + '\\RNG\\OS' => false, ]; diff --git a/ext/standard/tests/rng/class_clone.phpt b/ext/standard/tests/rng/class_clone.phpt index 3b544c34504e4..c07d6c3981069 100644 --- a/ext/standard/tests/rng/class_clone.phpt +++ b/ext/standard/tests/rng/class_clone.phpt @@ -4,13 +4,13 @@ Test class: clone RNG classes. $is_seed) { - $rng1 = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); - $rng1->next(); + $rng1 = $is_seed ? new $class(\random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + \rng_next($rng1); $rng2 = clone $rng1; - $rng1_value = $rng1->next(); - $rng2_value = $rng2->next(); + $rng1_value = \rng_next($rng1); + $rng2_value = \rng_next($rng2); if ($rng1_value !== $rng2_value) { die("NG, state is not cloned. RNG class: ${class} RNG1 value: ${rng1_value} RNG2 value: ${rng2_value}"); diff --git a/ext/standard/tests/rng/class_inheritance.phpt b/ext/standard/tests/rng/class_inheritance.phpt index c2cc98a1e8776..864b12e8ab36c 100644 --- a/ext/standard/tests/rng/class_inheritance.phpt +++ b/ext/standard/tests/rng/class_inheritance.phpt @@ -9,9 +9,6 @@ foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class = if (! $rng instanceof \RNG\RNGInterface) { die("NG, ${class} has not implemented \\RNG\\RNGInterface."); } - if (! $rng instanceof \RNG\RNG64Interface) { - die("NG, ${class} has not implemented \\RNG\\RNG64Interface."); - } } die('OK, inheritance is corrected.'); diff --git a/ext/standard/tests/rng/class_serialize.phpt b/ext/standard/tests/rng/class_serialize.phpt index a4a5bff10cef6..c92dd977886bd 100644 --- a/ext/standard/tests/rng/class_serialize.phpt +++ b/ext/standard/tests/rng/class_serialize.phpt @@ -3,19 +3,19 @@ Test class: serialize in supported RNG classes. --FILE-- $is_seed) { - $e = explode('\\', $class); - $define_class = 'X' . end($e); + $e = \explode('\\', $class); + $define_class = 'X' . \end($e); eval("class ${define_class} extends ${class} { public \$foo; public \$bar; public \$baz; }"); - $t = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $t = $is_seed ? new $class(\random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); $t->foo = 'bar'; $t->bar = 1234; $t->baz = [1, 2, 3, 4]; - $t->next(); + \rng_next($t); - $s = serialize($t); - $t_next = $t->next(); - $ut = unserialize($s); - $ut_next = $ut->next(); + $s = \serialize($t); + $t_next = \rng_next($t); + $ut = \unserialize($s); + $ut_next = \rng_next($ut); if ($ut_next !== $t_next) { die("NG, broken detected. class: ${class} method: next() correct: ${t_next} result: ${ut_next}"); } @@ -26,7 +26,7 @@ foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_serializable_rng_classes.inc' $ut->baz[2] !== 3 || $ut->baz[3] !== 4 ) { - die('NG, broken detected in properties: ' . print_r($ut, true)); + die('NG, broken detected in properties: ' . \print_r($ut, true)); } } die('OK, serialize / unserialize works correctly.'); diff --git a/ext/standard/tests/rng/class_serialize_64.phpt b/ext/standard/tests/rng/class_serialize_64.phpt index fedea6d10a41f..f3965050b0993 100644 --- a/ext/standard/tests/rng/class_serialize_64.phpt +++ b/ext/standard/tests/rng/class_serialize_64.phpt @@ -9,19 +9,19 @@ if (PHP_INT_SIZE < 8) { --FILE-- $is_seed) { - $e = explode('\\', $class); - $define_class = 'X' . end($e); + $e = \explode('\\', $class); + $define_class = 'X' . \end($e); eval("class ${define_class} extends ${class} { public \$foo; public \$bar; public \$baz; }"); - $t = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $t = $is_seed ? new $class(\random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); $t->foo = 'bar'; $t->bar = 1234; $t->baz = [1, 2, 3, 4]; - $t->next(); + \rng_next64($t); - $s = serialize($t); - $t_next64 = $t->next64(); - $ut = unserialize($s); - $ut_next64 = $ut->next64(); + $s = \serialize($t); + $t_next64 = \rng_next64($t); + $ut = \unserialize($s); + $ut_next64 = \rng_next64($ut); if ($ut_next64 !== $t_next64) { die("NG, broken detected. class: ${class} method: next64() correct: ${t_next64} result: ${ut_next64}"); } @@ -32,7 +32,7 @@ foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_serializable_rng_classes.inc' $ut->baz[2] !== 3 || $ut->baz[3] !== 4 ) { - die('NG, broken detected in properties: ' . print_r($ut, true)); + die('NG, broken detected in properties: ' . \print_r($ut, true)); } } die('OK, serialize / unserialize works correctly.'); diff --git a/ext/standard/tests/rng/class_userland.phpt b/ext/standard/tests/rng/class_userland.phpt index 95f15333cd40e..2ce37862806e5 100644 --- a/ext/standard/tests/rng/class_userland.phpt +++ b/ext/standard/tests/rng/class_userland.phpt @@ -19,16 +19,18 @@ class FixedNumberGenerator implements \RNG\RNGInterface } $rng = new FixedNumberGenerator(); -$array = range(1, 100); +$array = \range(1, 100); -$rng->next() . PHP_EOL; -$rng->next64() . PHP_EOL; -array_rand($array, 1, $rng); -array_rand($array, 2, $rng); -shuffle($array, $rng); -str_shuffle('foobar', $rng); -rng_rand($rng, 1, 1000) . PHP_EOL; -rng_bytes($rng, 100) . PHP_EOL; +\rng_next($rng); +if (PHP_INT_SIZE >= 8) { + \rng_next64($rng); +} +\array_rand($array, 1, $rng); +\array_rand($array, 2, $rng); +\shuffle($array, $rng); +\str_shuffle('foobar', $rng); +\rng_int($rng, 1, 1000); +\rng_bytes($rng, 100); class XorShift128PlusEx extends \RNG\XorShift128Plus { @@ -47,8 +49,8 @@ $origin = new \RNG\XorShift128Plus(12345); $extend = new XorShift128PlusEx(12345); for ($i = 0; $i < 100000; $i++) { - $origin_next = $origin->next(); - $extend_next = $extend->next(); + $origin_next = \rng_next($origin, false); + $extend_next = \rng_next($extend, false); if (($origin_next + 1) !== $extend_next) { die("NG, userland extended class is broken."); diff --git a/ext/standard/tests/rng/class_userland_extend.phpt b/ext/standard/tests/rng/class_userland_extend.phpt deleted file mode 100644 index 84d7c6e034a3d..0000000000000 --- a/ext/standard/tests/rng/class_userland_extend.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Test class: userland implemented extended classes. ---FILE-- -next(); - $extend_next = $extend->next(); - - if (($origin_next + 1) !== $extend_next) { - die("NG, userland extended class is broken."); - } -} - -die('OK, userland implementation extended class works correctly.'); -?> ---EXPECT-- -OK, userland implementation extended class works correctly. diff --git a/ext/standard/tests/rng/function_array_rand.phpt b/ext/standard/tests/rng/function_array_rand.phpt index e056f557a3479..747af59997082 100644 --- a/ext/standard/tests/rng/function_array_rand.phpt +++ b/ext/standard/tests/rng/function_array_rand.phpt @@ -5,13 +5,13 @@ Test function: array_rand() function with RNGs. const SEED = 1234; -// Note: OSRNG fail in rare cases (it's truly random result) +// Note: OS fail in rare cases (it's truly random result) $array = ['a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25]; // one key foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { $rng = $is_seed ? new $class(SEED) : new $class(); foreach ($array as $key => $value) { - if (array_rand($array, 1, $rng) !== $key) { + if (\array_rand($array, 1, $rng) !== $key) { continue 2; } } @@ -20,10 +20,10 @@ foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class = // more keys. foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { $rng = $is_seed ? new $class(SEED) : new $class(); - [$key1, $key2] = array_rand($array, 2, $rng); + [$key1, $key2] = \array_rand($array, 2, $rng); if ( - ! array_key_exists($key1, $array) || - ! array_key_exists($key2, $array) || + ! \array_key_exists($key1, $array) || + ! \array_key_exists($key2, $array) || ($key1 === 'a' && $key2 === 'b') ) { die("NG, Failed get multiple random keys. RNG class: ${class}"); diff --git a/ext/standard/tests/rng/function_rng_bytes.phpt b/ext/standard/tests/rng/function_rng_bytes.phpt index ca7f733cbf555..77db1baff79a0 100644 --- a/ext/standard/tests/rng/function_rng_bytes.phpt +++ b/ext/standard/tests/rng/function_rng_bytes.phpt @@ -7,10 +7,10 @@ const SEED = 1234; foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { $rng = $is_seed ? new $class(SEED) : new $class(); - foreach (range(0, 999) as $i) { - $next = rng_bytes($rng, 100); + foreach (\range(0, 999) as $i) { + $next = \rng_bytes($rng, 100); - if (strlen($next) !== 100) { + if (\strlen($next) !== 100) { die("NG, invalid bytes: ${next}."); } } diff --git a/ext/standard/tests/rng/function_rng_bytes_string.phpt b/ext/standard/tests/rng/function_rng_bytes_string.phpt index a7a7771307ef9..7c3bd0839031b 100644 --- a/ext/standard/tests/rng/function_rng_bytes_string.phpt +++ b/ext/standard/tests/rng/function_rng_bytes_string.phpt @@ -14,6 +14,11 @@ class StringGenerator implements \RNG\RNGInterface return $this->$method(); } + public function next64(): int + { + return $this->next(); + } + private function gen0(): int { $t = ord('l'); @@ -47,17 +52,17 @@ class StringGenerator implements \RNG\RNGInterface } } -$result = rng_bytes(new StringGenerator(), 12); +$result = \rng_bytes(new StringGenerator(), 12); if ($result !== 'Hello world.') { die("NG, rng_bytes() invalid result: ${result}"); } -$result = rng_bytes(new StringGenerator(), 4); +$result = \rng_bytes(new StringGenerator(), 4); if ($result !== 'Hell') { die("NG, rng_bytes() invalid result: ${result}"); } -$result = rng_bytes(new StringGenerator(), 2); +$result = \rng_bytes(new StringGenerator(), 2); if ($result !== 'He') { die("NG, rng_bytes() invalid result: ${result}"); } diff --git a/ext/standard/tests/rng/function_rng_rand.phpt b/ext/standard/tests/rng/function_rng_int.phpt similarity index 54% rename from ext/standard/tests/rng/function_rng_rand.phpt rename to ext/standard/tests/rng/function_rng_int.phpt index dd033181ca76e..53909e411206f 100644 --- a/ext/standard/tests/rng/function_rng_rand.phpt +++ b/ext/standard/tests/rng/function_rng_int.phpt @@ -1,5 +1,5 @@ --TEST-- -Test function: rng_rand() function. +Test function: rng_int() function. --FILE-- $is_seed) { $rng = $is_seed ? new $class(SEED) : new $class(); - foreach (range(0, 999) as $i) { - $next = rng_rand($rng, 1, 10000); + foreach (\range(0, 999) as $i) { + $next = \rng_int($rng, 1, 10000); - if ($next < 0 || $next > 10000) { + if ($next < 1 || $next > 10000) { die("NG, invalid number: ${next}."); } } } -die('OK, rng_rand() works correctly.'); +die('OK, rng_int() works correctly.'); ?> --EXPECT-- -OK, rng_rand() works correctly. +OK, rng_int() works correctly. diff --git a/ext/standard/tests/rng/function_rng_rand_64.phpt b/ext/standard/tests/rng/function_rng_int_64.phpt similarity index 64% rename from ext/standard/tests/rng/function_rng_rand_64.phpt rename to ext/standard/tests/rng/function_rng_int_64.phpt index 59e33edf75fe6..cf0599c91ae42 100644 --- a/ext/standard/tests/rng/function_rng_rand_64.phpt +++ b/ext/standard/tests/rng/function_rng_int_64.phpt @@ -1,5 +1,5 @@ --TEST-- -Test function: rng_rand() function in 64bit range. +Test function: rng_int() function in 64bit range. --SKIPIF-- $is_seed) { $rng = $is_seed ? new $class(SEED) : new $class(); - foreach (range(0, 999) as $i) { - $next = rng_rand($rng, 4294967296, PHP_INT_MAX); + foreach (\range(0, 999) as $i) { + $next = \rng_int($rng, 4294967296, PHP_INT_MAX); if ($next < 4294967296) { die("NG, invalid number: ${next}."); } } } -die('OK, rng_rand() works correctly on 64bit.'); +die('OK, rng_int() works correctly on 64bit.'); ?> --EXPECT-- -OK, rng_rand() works correctly on 64bit. +OK, rng_int() works correctly on 64bit. diff --git a/ext/standard/tests/rng/function_shuffle.phpt b/ext/standard/tests/rng/function_shuffle.phpt index 76808585d337f..c32164a58aad7 100644 --- a/ext/standard/tests/rng/function_shuffle.phpt +++ b/ext/standard/tests/rng/function_shuffle.phpt @@ -6,10 +6,10 @@ Test function: shuffle() function with RNGs. const SEED = 1234; foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { - $array = range(0, 999); + $array = \range(0, 999); $rng = $is_seed ? new $class(SEED) : new $class(); - shuffle($array, $rng); - foreach (range(0, 999) as $i) { + \shuffle($array, $rng); + foreach (\range(0, 999) as $i) { foreach ($array as $key => $value) { if ($key !== $i) { break 2; diff --git a/ext/standard/tests/rng/function_str_shuffle.phpt b/ext/standard/tests/rng/function_str_shuffle.phpt index 2e5ed9eed9333..d1e40af051859 100644 --- a/ext/standard/tests/rng/function_str_shuffle.phpt +++ b/ext/standard/tests/rng/function_str_shuffle.phpt @@ -8,8 +8,8 @@ const SEED = 1234; foreach (include(__DIR__ . DIRECTORY_SEPARATOR . '_rng_classes.inc') as $class => $is_seed) { $string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; $rng = $is_seed ? new $class(SEED) : new $class(); - $shuffled_string = str_shuffle($string, $rng); - for ($i = 0; $i < strlen($string); $i++) { + $shuffled_string = \str_shuffle($string, $rng); + for ($i = 0; $i < \strlen($string); $i++) { if ($string[$i] !== $shuffled_string[$i]) { continue 2; } diff --git a/ext/standard/tests/rng/method_next.phpt b/ext/standard/tests/rng/method_next.phpt index fb6d3c5b8a7cd..b3b5b7bcf0b6f 100644 --- a/ext/standard/tests/rng/method_next.phpt +++ b/ext/standard/tests/rng/method_next.phpt @@ -3,7 +3,7 @@ Test method: next() call. --FILE-- $is_seed) { - $rng = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $rng = $is_seed ? new $class(\random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); for ($i = 1; $i <= 10000; $i++) { $next = $rng->next(); } diff --git a/ext/standard/tests/rng/method_next_64.phpt b/ext/standard/tests/rng/method_next_64.phpt index de9de123ed200..a96e02b790948 100644 --- a/ext/standard/tests/rng/method_next_64.phpt +++ b/ext/standard/tests/rng/method_next_64.phpt @@ -1,15 +1,9 @@ --TEST-- Test method: next64() call. ---SKIPIF-- - --FILE-- $is_seed) { - $rng = $is_seed ? new $class(random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); + $rng = $is_seed ? new $class(\random_int(PHP_INT_MIN, PHP_INT_MAX)) : new $class(); for ($i = 1; $i <= 10000; $i++) { $next = $rng->next64(); } diff --git a/ext/standard/tests/rng/mt19937_consistency.phpt b/ext/standard/tests/rng/mt19937_consistency.phpt index 5ae843b180d78..26d5e1b553785 100644 --- a/ext/standard/tests/rng/mt19937_consistency.phpt +++ b/ext/standard/tests/rng/mt19937_consistency.phpt @@ -4,11 +4,11 @@ Test class: MT19937: consistent for mt_srand() / mt_rand() next() >> 1 & PHP_INT_MAX); // virtually logical shift + $rng_next = \rng_next($rng); $func_next = \mt_rand(); if ($rng_next !== $func_next) { @@ -16,20 +16,20 @@ for ($i = 0; $i < 100; $i++) { } } // shuffle - $rng_array = range(0, 99); - $func_array = range(0, 99); - shuffle($rng_array, $rng); - shuffle($func_array); + $rng_array = \range(0, 99); + $func_array = \range(0, 99); + \shuffle($rng_array, $rng); + \shuffle($func_array); for ($k = 0; $k < 100; $k++) { if ($rng_array[$k] !== $func_array[$k]) { die("NG, Incosistent result MT19937: {$rng_array[$k]} shuffle: {$func_array[$k]} i: ${i} k: ${k}"); } } // str_shuffle - $rng_string = random_bytes(100); + $rng_string = \random_bytes(100); $func_string = $rng_string; - $rng_string = str_shuffle($rng_string); - $func_string = str_shuffle($func_string, $rng); + $rng_string = \str_shuffle($rng_string); + $func_string = \str_shuffle($func_string, $rng); for ($k = 0; $k < 100; $k++) { if ($rng_string[$k] !== $func_string[$k]) { die("NG, Incosistent result MT19937: {$rng_string[$k]} str_shuffle: {$func_string[$k]} i: ${i} k: ${k}"); @@ -39,8 +39,8 @@ for ($i = 0; $i < 100; $i++) { $rng_data = ['a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25]; $func_data = $rng_data; for ($k = 0; $k < 26; $k++) { - $rng_result = array_rand($rng_data, 1, $rng); - $func_result = array_rand($func_data, 1); + $rng_result = \array_rand($rng_data, 1, $rng); + $func_result = \array_rand($func_data, 1); if ($rng_result !== $func_result) { die("NG, Incosistent result MT19937: {$rng_result} array_rand (1 key): {$func_result} i: ${i} k: ${k}"); } @@ -49,8 +49,8 @@ for ($i = 0; $i < 100; $i++) { $rng_data = ['a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25]; $func_data = $rng_data; for ($k = 0; $k < 26; $k++) { - [$rng_result1, $rng_result2] = array_rand($rng_data, 2, $rng); - [$func_result1, $func_result2] = array_rand($func_data, 2); + [$rng_result1, $rng_result2] = \array_rand($rng_data, 2, $rng); + [$func_result1, $func_result2] = \array_rand($func_data, 2); if ($rng_result1 !== $func_result1 || $rng_result2 !== $func_result2) { die("NG, Incosistent result MT19937: {$rng_result1} / ${rng_result2} array_rand (2 key): {$func_result1} / ${func_result2} i: ${i} k: ${k}"); } diff --git a/ext/standard/tests/rng/mt19937_result.phpt b/ext/standard/tests/rng/mt19937_result.phpt index 5afc1eac54b70..c33094dafbccb 100644 --- a/ext/standard/tests/rng/mt19937_result.phpt +++ b/ext/standard/tests/rng/mt19937_result.phpt @@ -3,7 +3,7 @@ Test class: MT19937: consistent result. --FILE-- 1996335345, 1 => 1911592690, @@ -1009,7 +1009,7 @@ $result = array ( $rng = new \RNG\MT19937(SEED); foreach ($result as $ret) { - $rng_next = rng_rand($rng); + $rng_next = \rng_next($rng); if ($ret !== $rng_next) { die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); } diff --git a/ext/standard/tests/rng/mt19937_result_64.phpt b/ext/standard/tests/rng/mt19937_result_64.phpt index 9685fcec7f241..e5bcdc4721601 100644 --- a/ext/standard/tests/rng/mt19937_result_64.phpt +++ b/ext/standard/tests/rng/mt19937_result_64.phpt @@ -9,1013 +9,1013 @@ if (PHP_INT_SIZE < 8) { --FILE-- next64(); } var_export($arr);' +// ./sapi/cli/php -r '$r = new \RNG\MT19937(12345); $a = []; for ($i = 0; $i < 1000; $i++) { $a[] = rng_next64($r); } var_export($a);' $result = array ( - 0 => -1298354032638611995, - 1 => 5836098993699293313, - 2 => 3392703261234277801, - 3 => 3773471124928680318, - 4 => -7974065807368502750, - 5 => -7460883356170798335, - 6 => -654591539783086735, - 7 => -6397753339937154418, - 8 => -4631855007149765541, - 9 => -6390507853669706378, - 10 => -4653840397050535054, - 11 => -713764701953347317, - 12 => 154736802364647050, - 13 => 1963552194952435410, - 14 => 5510110880054540551, - 15 => -6338095008519208729, - 16 => -3508339191409949667, - 17 => -2357938176985657929, - 18 => -652136702356950339, - 19 => -5097105691610658981, - 20 => -6595166134903412700, - 21 => -5212060869759209489, - 22 => 8625679179711580924, - 23 => 6005977249153676933, - 24 => 8110011575351034487, - 25 => -4986356374521057394, - 26 => -110411362861080239, - 27 => -5960627993306379899, - 28 => -3858643550111144651, - 29 => 3152811605224055880, - 30 => 495281634690674914, - 31 => -3682519061263046395, - 32 => -1776005691041470381, - 33 => 455195670278792590, - 34 => 9071136937505938000, - 35 => -8739049689330811610, - 36 => -7445732931968700448, - 37 => 958447497090921477, - 38 => -1935256691803255732, - 39 => -5012604146867671540, - 40 => -3350850779428771266, - 41 => -9219262984178842478, - 42 => -3501387414075530670, - 43 => 1770306876347866926, - 44 => 4038915478038249751, - 45 => 4772524321543247623, - 46 => 8635027014520198207, - 47 => 8473939944480035328, - 48 => -5358598721057174868, - 49 => 3284498216867551630, - 50 => -8643223960532744533, - 51 => 3094297982135069923, - 52 => -4264630531593224957, - 53 => -1325019537204297210, - 54 => -7203570542402818127, - 55 => 2770396547958162300, - 56 => 9032018447984850213, - 57 => 6960785775196755499, - 58 => -2792810943191082794, - 59 => -1639966582550029759, - 60 => 7080759088998192901, - 61 => 5819872255997237992, - 62 => -7961722632864028551, - 63 => 3464631228428906708, - 64 => 2321366769504866425, - 65 => -5762840308337125075, - 66 => -3696603640812287884, - 67 => -7866861898200453685, - 68 => -493819727695128187, - 69 => -6750505253117400458, - 70 => -2058255919707862647, - 71 => 9138789271661798525, - 72 => 6486180062338238785, - 73 => -5271519239924383335, - 74 => -9150892595068865547, - 75 => 4162279061252991309, - 76 => 4518980733272769928, - 77 => -3822152476653792657, - 78 => 9134318808161933146, - 79 => -1566245377009879572, - 80 => -1007711810009430432, - 81 => -8610345554941663163, - 82 => 4657666303540708943, - 83 => -5149186252015253732, - 84 => 6778048861135845124, - 85 => 9198440228778986738, - 86 => 4179571914677089366, - 87 => 6522134891585035509, - 88 => -6440647688815379116, - 89 => 5772593006367276697, - 90 => -4266077988104033019, - 91 => -4024395138091764610, - 92 => -2722564504079640749, - 93 => -924075922164664144, - 94 => 1979758274959812003, - 95 => -1646826503904481997, - 96 => 6199123627645298285, - 97 => -3202715840780070834, - 98 => -1879711524954947011, - 99 => 787958398515564458, - 100 => 3611780175214423832, - 101 => 5432590600945396492, - 102 => -6880637691982512501, - 103 => 1590535616184670436, - 104 => 2636870143694704601, - 105 => -8931424313021756903, - 106 => -5730640997154623263, - 107 => -2644786864245688770, - 108 => -6505028796475084170, - 109 => -7717773127317598990, - 110 => -5328970154833455411, - 111 => 4656269175089175703, - 112 => -1841728806467775604, - 113 => 8158878559794074293, - 114 => 378542463650683894, - 115 => -744123073029574119, - 116 => -6415308673353835845, - 117 => -8979759727090384584, - 118 => -5859490452627479156, - 119 => 9030426278940261143, - 120 => -1356016984039502986, - 121 => -8930441935939769523, - 122 => 1331114927639073653, - 123 => -7978063769630020688, - 124 => -7097510558660725174, - 125 => -1078280472920444094, - 126 => 7662101443215512126, - 127 => 4878056538246497663, - 128 => 1796586818700619001, - 129 => 8962244049475283635, - 130 => 8571516933595884559, - 131 => 548962472926869090, - 132 => -5639585442283654895, - 133 => -5221404194928332658, - 134 => -4984099484011911936, - 135 => 7643427270541295655, - 136 => 278524452907077118, - 137 => -1679111960602691092, - 138 => -3885276786282854226, - 139 => 3047386825968502474, - 140 => 5769882576438862440, - 141 => -7176792422584779956, - 142 => 6723659075086080406, - 143 => 2878403836392144284, - 144 => 3270678069058900432, - 145 => -2437005409996287556, - 146 => 5351302168608791167, - 147 => -7652085313150896467, - 148 => 8374727214459615129, - 149 => 7584897735062938491, - 150 => -2165012449405930837, - 151 => -5668536604008667678, - 152 => 5151684114263176453, - 153 => 1188712465327085540, - 154 => 3663958973691065032, - 155 => -1260230926584429461, - 156 => -2685595763286502687, - 157 => -834996760020847043, - 158 => 963904124300871488, - 159 => -7757378282541740312, - 160 => 8863591702688786162, - 161 => 400459910998276272, - 162 => 6892080971791219349, - 163 => 7638645436986862801, - 164 => -7306621909572786035, - 165 => -6055167339241504174, - 166 => -2972403175669949939, - 167 => -4067023586511689649, - 168 => 7391629584192145636, - 169 => -3790266658564140107, - 170 => -1971508492323999700, - 171 => 4842080115564572286, - 172 => -199280079276369937, - 173 => -2706006318568906179, - 174 => -4953372257765276574, - 175 => 6559028147399988675, - 176 => -2152928903706413560, - 177 => -2435724825273950163, - 178 => -815965107342160504, - 179 => 1978436855060560, - 180 => 305128482875869981, - 181 => 5793570005859834630, - 182 => -86401330550030585, - 183 => 2745691277683745058, - 184 => 3087562892541503441, - 185 => -4453559782371503653, - 186 => 1282595912348106348, - 187 => -5433056083407159958, - 188 => 8654571904944265830, - 189 => 187939471944096899, - 190 => -4153766511781204685, - 191 => -3796321442965086290, - 192 => 2759069321418590426, - 193 => 437254804636289566, - 194 => -4389148773726967597, - 195 => 4125986538072562393, - 196 => 4836264077342756432, - 197 => 8427754774290443075, - 198 => 4610337880454563808, - 199 => -7963762649129819930, - 200 => -2823403396962049916, - 201 => 6974705345195532705, - 202 => 7977573369285719408, - 203 => -3087631145065166613, - 204 => 6846175813381275494, - 205 => 748075847266167668, - 206 => -8214861129748320275, - 207 => 8324023999005111915, - 208 => -5067302577840675451, - 209 => 6981180018906260340, - 210 => -2939258085067648222, - 211 => 8657327988520164007, - 212 => -8067804747713402386, - 213 => -6249769008475799259, - 214 => 8526857487870208042, - 215 => -6942672964829812477, - 216 => 4092975191107610427, - 217 => -4927805681110351013, - 218 => 7040791761930199032, - 219 => 3594062965252892636, - 220 => 5002070287115602208, - 221 => 4597390719008736650, - 222 => 2806470308295775266, - 223 => -4217410739296532928, - 224 => 4711514842750834089, - 225 => 2352760622271696945, - 226 => -6176575726340819749, - 227 => 7614907236844367266, - 228 => -6128602992990192366, - 229 => -6275332898205192944, - 230 => 5633223851973528822, - 231 => 3711932054503167811, - 232 => 4095677534142454473, - 233 => 2213071813133980220, - 234 => 685212415328855287, - 235 => 629616541418744415, - 236 => 4251910738367627708, - 237 => 4212382417841061723, - 238 => -6919177827456091577, - 239 => -1981896293134245569, - 240 => -4063300884089626186, - 241 => -5138317070671117262, - 242 => 5726647022645750822, - 243 => 6697706950228926334, - 244 => 3617070490877609544, - 245 => -1189966281745833721, - 246 => -8084580741675661368, - 247 => -3370376190564890376, - 248 => 6436326826540713358, - 249 => -3694619677611852037, - 250 => 1920388405143893708, - 251 => -5310445665441370205, - 252 => -1522806425980045865, - 253 => -3623210408775271130, - 254 => 6034172565290796206, - 255 => 4705896757413678697, - 256 => 9131178400029907857, - 257 => 7629775426807034611, - 258 => 7838705910147836363, - 259 => 1372037585240111995, - 260 => -7316151130088451540, - 261 => -4663341819453308375, - 262 => -3734059547776894555, - 263 => 7037442493196279686, - 264 => -3741771534879698300, - 265 => 8703125422950807136, - 266 => -5139278178720944876, - 267 => 3490358096811829569, - 268 => 8016875821923010172, - 269 => -3256438668999762807, - 270 => -3204704378555092273, - 271 => 3496127992503949618, - 272 => 370819537543828499, - 273 => -5469618558411056947, - 274 => 6406003054512063805, - 275 => 7738479646946148188, - 276 => -4278004604042678869, - 277 => -684778739162135109, - 278 => -1981820249995944596, - 279 => 2489245407515010572, - 280 => -3729844633583065106, - 281 => -5864393251412528609, - 282 => -8668994046897751639, - 283 => -2472202050878891636, - 284 => -4551769339249583699, - 285 => 1719284339743952251, - 286 => 6077084982784102390, - 287 => 7606749177538350079, - 288 => 17793875401286251, - 289 => -7423642039108314820, - 290 => -5855706019643803170, - 291 => 6756687478660140968, - 292 => 7314112936654856973, - 293 => 8768828455972950210, - 294 => -7727711738139655511, - 295 => 2529733511344941033, - 296 => -10806620070156995, - 297 => -9088208860643977618, - 298 => 9095475254472073309, - 299 => 3447230800227437871, - 300 => 5461859807938846687, - 301 => -3716741050051511700, - 302 => 5437699719732428408, - 303 => -5587120437363502992, - 304 => 5035209009095986509, - 305 => -1613565283504100230, - 306 => 5507076759965846175, - 307 => -2031728649313406743, - 308 => -982800223771778197, - 309 => 3115891640940228319, - 310 => 6627756634394862007, - 311 => -5862793972879043370, - 312 => -1450062220691528702, - 313 => 2673382306618290735, - 314 => 1842357231431186421, - 315 => 7592731058794879777, - 316 => -458855890037088429, - 317 => 765660472431536626, - 318 => 3447960115308674819, - 319 => -7216956708971895623, - 320 => 1608901216369942546, - 321 => 5834486655591906131, - 322 => -7191725620940939251, - 323 => 3711387473271874298, - 324 => -5683484028244577256, - 325 => 4512571201078229687, - 326 => -5896101489210618166, - 327 => 8963968883865929180, - 328 => 4805281131471060642, - 329 => 5215638273390457205, - 330 => -1744109758922302424, - 331 => 5088399440043872330, - 332 => -2930301407563971575, - 333 => 3623390139093116187, - 334 => 6098187891143470570, - 335 => -984504852782893875, - 336 => -9111366226792188465, - 337 => 7441708998216678724, - 338 => 499197336626850738, - 339 => -6977044020412728996, - 340 => 6407448968010302022, - 341 => 5106044555868018261, - 342 => 1181602064519547209, - 343 => 6168416258165226464, - 344 => 1249027924661792236, - 345 => 70544880413519169, - 346 => 755722583308327124, - 347 => 6437081187932153620, - 348 => 1696257586554607506, - 349 => -8848613013391818064, - 350 => 3979881536324491606, - 351 => -153725183337475136, - 352 => 4928733180040853200, - 353 => -5899858037466232928, - 354 => -8739216649425747192, - 355 => 8115148273707940500, - 356 => -6243203713052129723, - 357 => 2486347603642699316, - 358 => -3913495114967021654, - 359 => 2545239381915424156, - 360 => -6771369907494882903, - 361 => 3941430150522290317, - 362 => 431198449908635493, - 363 => -6881853519600423605, - 364 => -6600914142987600109, - 365 => -6602028147467715254, - 366 => -2497303611498851751, - 367 => 6220268064906010195, - 368 => 7580844060182375540, - 369 => -7188351497219004776, - 370 => -1091250565421665344, - 371 => 2805330421209542479, - 372 => 3395270957383317775, - 373 => 2848883659592341185, - 374 => -5297456160259195274, - 375 => -1328476194575465921, - 376 => 7797202157164138947, - 377 => -8389998634457254843, - 378 => 5947026769020264245, - 379 => 2964478217432541475, - 380 => -5475878551949073974, - 381 => -4976038711371029838, - 382 => -730407386813125707, - 383 => 6834344662205755549, - 384 => -5225992335432309778, - 385 => -257125126380167808, - 386 => 2043300927213429507, - 387 => -4459896079677577634, - 388 => 2906360582882072450, - 389 => -3386171856880015486, - 390 => -8225282455270124604, - 391 => -7716084423460352461, - 392 => -1177906097073969510, - 393 => 8012301785433933675, - 394 => 9022803999032102653, - 395 => -6158805875765650395, - 396 => -6822454449106439632, - 397 => 2401853699459027135, - 398 => 6527269143079698217, - 399 => -6730785556063653938, - 400 => -1495000497961195925, - 401 => 1683573732922772324, - 402 => 1311233777163077492, - 403 => 7631632610572016661, - 404 => 3977877440315543501, - 405 => -8859996429402148739, - 406 => -8143978756991446653, - 407 => 8738225651171338227, - 408 => 3982137802642445433, - 409 => 4416867861726047692, - 410 => 3998115038649454677, - 411 => -6351391500569832968, - 412 => -2833540730440134023, - 413 => -1282705559961476907, - 414 => -3683713021298219523, - 415 => -5889568620103433743, - 416 => 3823216154325316542, - 417 => -4765536912806104721, - 418 => -5591123494080898128, - 419 => 7042219411268568421, - 420 => -2764814156156632799, - 421 => -8704812297616069631, - 422 => -1973634271097980396, - 423 => -3310095324729580740, - 424 => 4216531275946448793, - 425 => -3308903768913045729, - 426 => 2556007140344433309, - 427 => 8899954424026225017, - 428 => 2745070222524526352, - 429 => 8269565677923400423, - 430 => -6162015492513596269, - 431 => -3891664882912304583, - 432 => -6234616454172642240, - 433 => -5321656474895243125, - 434 => -2067443541267395350, - 435 => 2613447852721338030, - 436 => 2722188281392956282, - 437 => 6012362815553290953, - 438 => 587968275293676685, - 439 => -5759757920334230233, - 440 => -4339964662455361805, - 441 => 6456534141562255854, - 442 => -7083409418036919839, - 443 => -765542455511910851, - 444 => 5368973071210785102, - 445 => -5779762190138168592, - 446 => 778973365703234360, - 447 => 1152988533761580789, - 448 => -3423739709975031452, - 449 => 8054187112911133403, - 450 => 7232386088634304008, - 451 => 6099373128238475504, - 452 => 8442315342611096321, - 453 => -3037216819677177331, - 454 => 8610366116776791767, - 455 => 7771354890067484512, - 456 => -7916391535125519160, - 457 => -4813567905150306883, - 458 => 1016109457240081442, - 459 => -6932643457446308374, - 460 => -6990203142183759437, - 461 => 20485765888835646, - 462 => -7325321944650631122, - 463 => 741290029534325580, - 464 => -7641557003296509940, - 465 => 8271140531326049814, - 466 => 6525171678446259100, - 467 => -1226243017375594294, - 468 => 4930001751236623806, - 469 => 5189057710675562203, - 470 => -9132872942906065329, - 471 => -6515277209601366256, - 472 => -542824357291915904, - 473 => 661785793816538914, - 474 => 7806659669015700854, - 475 => -7594301610626462911, - 476 => -4949219436836948991, - 477 => 3237607862161438214, - 478 => -9028965802280970316, - 479 => -9218122208963647477, - 480 => -1978087993815284947, - 481 => 7059249924119544850, - 482 => -6219064407190101537, - 483 => 863520939650179304, - 484 => -4589120361687168674, - 485 => 6802887958390083749, - 486 => -958702513632827937, - 487 => 6405174686132264739, - 488 => -5831141267961463930, - 489 => -3234915490171904541, - 490 => 8969784566778476363, - 491 => -291903683860336619, - 492 => -7308341062668973273, - 493 => -4434139096627481945, - 494 => -5819639760925231202, - 495 => -1246700596974694796, - 496 => -926294514070292453, - 497 => -182417491352012328, - 498 => 2327156079585512328, - 499 => -431642319120391907, - 500 => 4226253332420415716, - 501 => 3432135224167894613, - 502 => -9053451211515940047, - 503 => -8660789102663595156, - 504 => 5213773757658558849, - 505 => 5721470484654807480, - 506 => 5716357735476852954, - 507 => 4914007671303813281, - 508 => -7499871566740484247, - 509 => 4005422196609743888, - 510 => 7422654629456619790, - 511 => 5323015293454485721, - 512 => 3206797011493482038, - 513 => 4163679694653236151, - 514 => -209528889153889728, - 515 => 8006834208609437950, - 516 => -3169348507731268351, - 517 => -7885746341771093857, - 518 => -6421306488165958557, - 519 => -4985450993192220349, - 520 => 7217909293569389752, - 521 => 7247033194845905848, - 522 => -2590822493528118400, - 523 => -3504519655762209803, - 524 => -3015233104408826313, - 525 => 3467765228043788357, - 526 => 6633389193095526437, - 527 => 8891035241982068531, - 528 => -625849196951478227, - 529 => -8055449978018730212, - 530 => -3181973617418353987, - 531 => 1403937661980399111, - 532 => -8243149886504182713, - 533 => -8339026628722614025, - 534 => -1744257813675245993, - 535 => 6815863021825623249, - 536 => -1823227488350702482, - 537 => 2594184571987531057, - 538 => 1829432382283380735, - 539 => -494681499403531782, - 540 => -1069080623535206114, - 541 => -7545696786544732734, - 542 => 958453462232008483, - 543 => 925135452714226313, - 544 => 5987853204506605232, - 545 => 6931359661286250539, - 546 => -4350677104183539217, - 547 => -2596086968000715775, - 548 => -8380203162563515613, - 549 => 5974070071764339034, - 550 => 7485963024966894317, - 551 => 2023013354072520527, - 552 => 2532577814444057273, - 553 => -4696744620723997587, - 554 => -2279730966827752471, - 555 => 4777510222850776967, - 556 => -5799625610128859789, - 557 => 6624437544552774777, - 558 => 110996273954605107, - 559 => -4405435640494169605, - 560 => 7637365026700900170, - 561 => 6159219884810196150, - 562 => 5128989505659853244, - 563 => -7516787031653864745, - 564 => 5997048393883803686, - 565 => -1165735675048191965, - 566 => 1770573307792507038, - 567 => -2152813512726316937, - 568 => -7968666273089304190, - 569 => 1142286482949663692, - 570 => -2306052175543930643, - 571 => 4147801442238039632, - 572 => -3700725306810280670, - 573 => -3654761423580211775, - 574 => 534116591750101426, - 575 => -6878809272645857983, - 576 => -7293118472324213901, - 577 => 1442674233198961155, - 578 => -4188267440491322022, - 579 => 2643725095778940725, - 580 => 8553471236938857707, - 581 => 1791375837589172121, - 582 => -7934789200660844641, - 583 => 7448185700812831993, - 584 => -7626276709513080360, - 585 => -4635549146494647448, - 586 => -2036265356195773324, - 587 => 6998513026958591645, - 588 => 5394496858021440185, - 589 => -9051997413327359563, - 590 => -8618067955393091081, - 591 => 1944685601971007433, - 592 => 847462013631544026, - 593 => -6972995659873629382, - 594 => -3275313172533142906, - 595 => 1015743613198235257, - 596 => -3726732214241596155, - 597 => 4505523512778000656, - 598 => -3624088937191829578, - 599 => 5500359135442881393, - 600 => 8619627912972281301, - 601 => -1239258588820677738, - 602 => -1664693509665310555, - 603 => 2396743401664685216, - 604 => -8679235498747088157, - 605 => -7025151463495202113, - 606 => -6924626970252278689, - 607 => -6515227054268789472, - 608 => 6125729733533694965, - 609 => 2107030272592464378, - 610 => -7911725719775211224, - 611 => 5570759595421690039, - 612 => 3569548336753860541, - 613 => -8029762795433776209, - 614 => -7185326798872019861, - 615 => 836186908667673461, - 616 => -269771810547353474, - 617 => 1913426120502000335, - 618 => 7487484489747998491, - 619 => -6169345947734947898, - 620 => 3634230765129958076, - 621 => 4460062308506470947, - 622 => -6951241313282668555, - 623 => -3712622117534278665, - 624 => -8399976431522098821, - 625 => 3644843592918599388, - 626 => -3982251042558304021, - 627 => -3424936434689663469, - 628 => -5333156399864152748, - 629 => -1032229273878341508, - 630 => -2675744592881910139, - 631 => -671898552489622434, - 632 => 8571080331913515013, - 633 => 8946583088011533569, - 634 => -7628305275784492063, - 635 => -1070116343844837426, - 636 => 6867413699979618179, - 637 => -7411122471327938208, - 638 => -7127595062469485472, - 639 => -8115384595794422681, - 640 => 2186268474755897419, - 641 => 7432415476353419818, - 642 => 4085932814061005653, - 643 => -3905568684092134131, - 644 => -4353659533339152689, - 645 => 3216706487954116132, - 646 => -5093998474846854795, - 647 => -1391582977849549661, - 648 => 8779450224925116936, - 649 => -1605994067058658692, - 650 => 8069011063083699263, - 651 => 1214912306565431735, - 652 => 6709185224030426434, - 653 => 3494714947770452926, - 654 => 2736253495598964093, - 655 => 3893750144887449922, - 656 => -2221733860098778130, - 657 => -3361990978740614629, - 658 => -6796450427939454443, - 659 => -824892422555546719, - 660 => 2196090383185315343, - 661 => -7336783028317660216, - 662 => 6113705576716580252, - 663 => -3292178199597353218, - 664 => -6275790122370780025, - 665 => 7795060189592870843, - 666 => -5237345866487717212, - 667 => 3971378925938244568, - 668 => 310511762720174763, - 669 => 5178566173762408616, - 670 => -7346949169146542186, - 671 => 8495757122964278799, - 672 => -5337255259936637926, - 673 => 3037733426273005184, - 674 => -1102449995278023704, - 675 => -821832531487791235, - 676 => -355453583603335536, - 677 => 1085220522087750357, - 678 => -4789325384060347950, - 679 => -7366668779145444980, - 680 => 1640899317892579901, - 681 => -196622906433231919, - 682 => -8322390630144645323, - 683 => -6005007200754143497, - 684 => -5074829020746811174, - 685 => -7959872358947582320, - 686 => -8716310455813060668, - 687 => 2780900918973730265, - 688 => 4432466677120026430, - 689 => 7426314140033950121, - 690 => 1251377276326690870, - 691 => -4457011914420959063, - 692 => 6321553483289540505, - 693 => -189284966388869317, - 694 => -2055683178109552429, - 695 => -1133714120299781790, - 696 => -4812740959588225086, - 697 => 497081426198945048, - 698 => 7053959145109496304, - 699 => 194177648801788177, - 700 => 1203319287616851715, - 701 => -5877267356421451651, - 702 => -246089255833701575, - 703 => -6156589260176310872, - 704 => 7657299012824609996, - 705 => 759280966141940849, - 706 => -1950063216062768347, - 707 => -5408825696242340486, - 708 => 8834133303405207394, - 709 => 3977348485336283979, - 710 => 1508317718870078411, - 711 => -6028355218356815399, - 712 => -96307019843728889, - 713 => -7498005234917979847, - 714 => -2948113434728289276, - 715 => 2821947051788881355, - 716 => -2284784641138358937, - 717 => -8396301253025908926, - 718 => -301746739587499856, - 719 => -4875434974310467948, - 720 => 1717081962620092095, - 721 => 5390581630300434712, - 722 => 5036849614102582208, - 723 => 1312788705614901494, - 724 => -5902535760706948288, - 725 => 4145408816407429086, - 726 => -8273369689407542529, - 727 => -4247504148622565610, - 728 => 3905508127712723295, - 729 => 5400995242359565655, - 730 => 6574738565688523867, - 731 => -804877697267484089, - 732 => -6267394527622144985, - 733 => -912884997929385534, - 734 => 1786891692964368860, - 735 => 4879652307292919330, - 736 => 5020060065260740150, - 737 => -3042104642060813779, - 738 => -3452264078002814917, - 739 => 5418623320032585862, - 740 => -6461711205384347745, - 741 => 7765980325798131650, - 742 => 1377080371099107696, - 743 => -4818163120178283337, - 744 => -7648572614337752949, - 745 => 6358050281888768959, - 746 => 4759318588921701176, - 747 => 5383092559346434924, - 748 => -4247724047889921915, - 749 => 7827238308909905925, - 750 => 5323210827028510809, - 751 => 4873290316302087875, - 752 => 5108252786882586519, - 753 => -2908018341348975358, - 754 => 3128979040632118883, - 755 => 4650177494953897610, - 756 => -7528573738490143686, - 757 => -454532917121241274, - 758 => 76206372321169060, - 759 => 4427515967358468331, - 760 => -5044887452325991064, - 761 => 4625051155082122176, - 762 => -1509715987152042346, - 763 => -9072995904907086207, - 764 => -9176663506919676151, - 765 => -5307057017128186184, - 766 => -6645106980515465240, - 767 => 5244458042518019000, - 768 => 180470411466752910, - 769 => -7475735498054393622, - 770 => -2932755929924686309, - 771 => 8976005851143810518, - 772 => -4043615981801487507, - 773 => 7609924944450376538, - 774 => 7006175996044522332, - 775 => -1873349750010439219, - 776 => -1905066750569003880, - 777 => -5156847339154749125, - 778 => 5254587227293151191, - 779 => 6270032818236809024, - 780 => 5260476949855499383, - 781 => -4065463299933196800, - 782 => 84354565623605763, - 783 => 1562209966349853341, - 784 => 8141604492556661497, - 785 => 4631374618485187663, - 786 => -1736344223779216019, - 787 => -2197326770774831313, - 788 => -5229275972873263151, - 789 => 4402800826240676548, - 790 => -1378139100744463677, - 791 => -560440813849750900, - 792 => -7780116978836695506, - 793 => 4962683724710060832, - 794 => 5550799649416556300, - 795 => -6911399791169399042, - 796 => -4061160008435427738, - 797 => 7767986280116902618, - 798 => -6327607332220513415, - 799 => 7814408278060204006, - 800 => 6488197001376391378, - 801 => -6924384915482591309, - 802 => -3477241868459142614, - 803 => 9107491680003162069, - 804 => 980456891018555793, - 805 => 8912255135604404421, - 806 => -9137887816350806099, - 807 => 8059710994414227496, - 808 => 6936265680368089049, - 809 => -4097427070116601925, - 810 => 1846107798437843309, - 811 => 303991876291152673, - 812 => -4014454182879547796, - 813 => -2708743804150289875, - 814 => 4126569063962323117, - 815 => -6882063929039426937, - 816 => 1192956279739966268, - 817 => 4407310915518636566, - 818 => 8481315617694569723, - 819 => -6222408302398288806, - 820 => 4015886037078550437, - 821 => 8668992204632718174, - 822 => -400460623494916111, - 823 => -8982573032552951989, - 824 => 8672392152272863731, - 825 => -6158611106603362555, - 826 => -8831923424312527212, - 827 => 4745777402059664803, - 828 => -3243529581453052992, - 829 => 2375666372984608944, - 830 => 3171802886905371406, - 831 => 3226555531453400753, - 832 => 7045559647732554081, - 833 => 1874064673696647081, - 834 => 7190478310326444036, - 835 => -3506460018416637627, - 836 => 6525568861281120853, - 837 => -2277844392017716335, - 838 => -759408331225391077, - 839 => -2974935420362143262, - 840 => 2122212695845544493, - 841 => -8072080039441853758, - 842 => 2000328268837054390, - 843 => -2289823516665995506, - 844 => 6456504585805602526, - 845 => -1886823662558486558, - 846 => 2290668569502564625, - 847 => -6680270166286945474, - 848 => -2351495868823170763, - 849 => 19656174082597500, - 850 => 5621089012976952414, - 851 => 531721331559439320, - 852 => -8306024656968054396, - 853 => 3231710671158139570, - 854 => -7562694142985621983, - 855 => 94458657530853252, - 856 => 5202401925693584748, - 857 => -4430946246341263396, - 858 => -2362197650096845438, - 859 => -9123368000514961544, - 860 => 8923514052293704273, - 861 => 880983619604951169, - 862 => -4596837920095355083, - 863 => -3111332798211493191, - 864 => -2471239256989082213, - 865 => -3195308506029059884, - 866 => 9215628726257374483, - 867 => 161704695809353319, - 868 => 6293919764797836573, - 869 => -4793887103447387348, - 870 => -1645668380029497255, - 871 => 5422568789965030410, - 872 => 3444141560165071933, - 873 => -2135820117029461126, - 874 => 7084800212012529111, - 875 => -7066833691557298423, - 876 => -7434487560691191093, - 877 => 5963843624415108696, - 878 => -6640153064232592304, - 879 => 8275036262341031359, - 880 => -5562431815530562054, - 881 => 2987223643365600456, - 882 => 3603721002299405849, - 883 => 8905940447518713266, - 884 => -9222216201508278235, - 885 => -4277904420357254828, - 886 => 3557641629025736238, - 887 => -144449870201775124, - 888 => 6000718247658497963, - 889 => -2840789983034124546, - 890 => -3354685848773275680, - 891 => -1723442823480586914, - 892 => -4806374104368124616, - 893 => 5841356859396356176, - 894 => 508357292543715601, - 895 => -8060514273610414272, - 896 => -799229186262249902, - 897 => 2877849229494537950, - 898 => -4469006376519612559, - 899 => 762642128687348774, - 900 => 3588789175675451971, - 901 => -8849709859862152666, - 902 => 8575850026410500273, - 903 => -3882861293540321843, - 904 => 2362261680537362722, - 905 => -1984586947110927454, - 906 => 3253859884740030522, - 907 => 8022132794119030823, - 908 => 2755083524648425779, - 909 => -5741280240352423818, - 910 => -3431028027852582513, - 911 => 3551914327964688721, - 912 => -7781962082361363318, - 913 => -5149102934125081290, - 914 => 8764647311272413826, - 915 => 4832145771203934497, - 916 => -4904446247206020211, - 917 => 6441731183741810927, - 918 => -6060411740430596086, - 919 => 1015647392864421793, - 920 => -1899175577452626000, - 921 => -8824089357560460450, - 922 => 5076969182290891584, - 923 => -2886902515647455214, - 924 => 8162196046706760127, - 925 => -6101262665834660182, - 926 => -135644501089363711, - 927 => -2717776315021831080, - 928 => -1225820791730929786, - 929 => -2543291547514274494, - 930 => 1236843312118227402, - 931 => 5383036634794926737, - 932 => 3621634061120232613, - 933 => 7581808175887087760, - 934 => 7732561353971308437, - 935 => -769827589121750359, - 936 => -1400439143539382496, - 937 => -301252394331355107, - 938 => 7034340125714281556, - 939 => -662471733306487756, - 940 => -7557352272589358112, - 941 => -9203713532702920147, - 942 => 5203772156086473502, - 943 => 2995125955123057037, - 944 => 8278668579692439832, - 945 => 6406503897815248551, - 946 => -8783312910216256464, - 947 => -8414856455170238684, - 948 => 199025223093326220, - 949 => 5470495000161012160, - 950 => 3104230518788455532, - 951 => -765386468698267359, - 952 => 4361395450210599155, - 953 => -3086964391909231663, - 954 => -5390964443116204656, - 955 => -8104413485721822709, - 956 => -5513399624850018243, - 957 => 3910788381801006263, - 958 => -5699313055370250965, - 959 => -6980140912659582482, - 960 => -5212140192577220982, - 961 => 2816767385968649045, - 962 => 1738667790038600161, - 963 => -900487993662467339, - 964 => 7451525460473151658, - 965 => -6577652361625746608, - 966 => -728802060191413007, - 967 => -3000963813011923874, - 968 => 2409767179539829923, - 969 => -9205398318637230327, - 970 => 3352185647164828069, - 971 => 929287429705404222, - 972 => -1935661750391601595, - 973 => 4907515611453535642, - 974 => 991763148255042634, - 975 => 9211322673922781230, - 976 => -4056233821525283506, - 977 => -8172867281523911365, - 978 => 2491297239385952127, - 979 => 7167975622581645303, - 980 => 4753230918151890989, - 981 => -8719321975173591025, - 982 => -1795406061378902577, - 983 => -2709572863074161296, - 984 => -3010079518298475214, - 985 => 3982255536584210398, - 986 => 2463559347523487796, - 987 => 2218073750032620742, - 988 => -2312771975564260983, - 989 => 1476263447905776349, - 990 => 7183419630152279613, - 991 => 3353963567092417736, - 992 => 7584439691865372095, - 993 => -3073536873323287273, - 994 => -397561346574583857, - 995 => 78386691422419006, - 996 => -8119215953105509619, - 997 => -4578854324907769257, - 998 => 7195056868313381403, - 999 => 5692761090142998691, + 0 => 8574195020535469810, + 1 => 2918049496849646656, + 2 => 1696351630617138900, + 3 => 1886735562464340159, + 4 => 5236339133170524433, + 5 => 5492930358769376640, + 6 => 8896076266963232440, + 7 => 6024495366886198599, + 8 => 6907444533279893037, + 9 => 6028118110019922619, + 10 => 6896451838329508281, + 11 => 8866489685878102149, + 12 => 77368401182323525, + 13 => 981776097476217705, + 14 => 2755055440027270275, + 15 => 6054324532595171443, + 16 => 7469202441149800974, + 17 => 8044402948361946843, + 18 => 8897303685676300638, + 19 => 6674819191049446317, + 20 => 5925788969403069458, + 21 => 6617341601975171063, + 22 => 4312839589855790462, + 23 => 3002988624576838466, + 24 => 4055005787675517243, + 25 => 6730193849594247111, + 26 => 9168166355424235688, + 27 => 6243058040201585858, + 28 => 7294050261799203482, + 29 => 1576405802612027940, + 30 => 247640817345337457, + 31 => 7382112506223252610, + 32 => 8335369191334040617, + 33 => 227597835139396295, + 34 => 4535568468752969000, + 35 => 4853847192189370003, + 36 => 5500505570870425584, + 37 => 479223748545460738, + 38 => 8255743690953147942, + 39 => 6717069963420940038, + 40 => 7547946647140390175, + 41 => 4613740544765354569, + 42 => 7472678329817010473, + 43 => 885153438173933463, + 44 => 2019457739019124875, + 45 => 2386262160771623811, + 46 => 4317513507260099103, + 47 => 4236969972240017664, + 48 => 6544072676326188374, + 49 => 1642249108433775815, + 50 => 4901760056588403541, + 51 => 1547148991067534961, + 52 => 7091056771058163329, + 53 => 8560862268252627203, + 54 => 5621586765653366744, + 55 => 1385198273979081150, + 56 => 4516009223992425106, + 57 => 3480392887598377749, + 58 => 7826966565259234411, + 59 => 8403388745579760928, + 60 => 3540379544499096450, + 61 => 2909936127998618996, + 62 => 5242510720422761532, + 63 => 1732315614214453354, + 64 => 1160683384752433212, + 65 => 6341951882686213270, + 66 => 7375070216448631866, + 67 => 5289941087754548965, + 68 => 8976462173007211714, + 69 => 5848119410296075579, + 70 => 8194244077000844484, + 71 => 4569394635830899262, + 72 => 3243090031169119392, + 73 => 6587612416892584140, + 74 => 4647925739320343034, + 75 => 2081139530626495654, + 76 => 2259490366636384964, + 77 => 7312295798527879479, + 78 => 4567159404080966573, + 79 => 8440249348349836022, + 80 => 8719516131850060592, + 81 => 4918199259383944226, + 82 => 2328833151770354471, + 83 => 6648778910847148942, + 84 => 3389024430567922562, + 85 => 4599220114389493369, + 86 => 2089785957338544683, + 87 => 3261067445792517754, + 88 => 6003048192447086250, + 89 => 2886296503183638348, + 90 => 7090333042802759298, + 91 => 7211174467808893503, + 92 => 7862089784814955433, + 93 => 8761334075772443736, + 94 => 989879137479906001, + 95 => 8399958784902534809, + 96 => 3099561813822649142, + 97 => 7622014116464740391, + 98 => 8283516274377302302, + 99 => 393979199257782229, + 100 => 1805890087607211916, + 101 => 2716295300472698246, + 102 => 5783053190863519557, + 103 => 795267808092335218, + 104 => 1318435071847352300, + 105 => 4757659880343897356, + 106 => 6358051538277464176, + 107 => 7900978604731931423, + 108 => 5970857638617233723, + 109 => 5364485473195976313, + 110 => 6558886959438048102, + 111 => 2328134587544587851, + 112 => 8302507633620888006, + 113 => 4079439279897037146, + 114 => 189271231825341947, + 115 => 8851310500339988748, + 116 => 6015717700177857885, + 117 => 4733492173309583516, + 118 => 6293626810541036230, + 119 => 4515213139470130571, + 120 => 8545363544835024315, + 121 => 4758151068884891046, + 122 => 665557463819536826, + 123 => 5234340152039765464, + 124 => 5674616757524413221, + 125 => 8684231800394553761, + 126 => 3831050721607756063, + 127 => 2439028269123248831, + 128 => 898293409350309500, + 129 => 4481122024737641817, + 130 => 4285758466797942279, + 131 => 274481236463434545, + 132 => 6403579315712948360, + 133 => 6612669939390609479, + 134 => 6731322294848819840, + 135 => 3821713635270647827, + 136 => 139262226453538559, + 137 => 8383816056553430262, + 138 => 7280733643713348695, + 139 => 1523693412984251237, + 140 => 2884941288219431220, + 141 => 5634975825562385830, + 142 => 3361829537543040203, + 143 => 1439201918196072142, + 144 => 1635339034529450216, + 145 => 8004869331856632030, + 146 => 2675651084304395583, + 147 => 5397329380279327574, + 148 => 4187363607229807564, + 149 => 3792448867531469245, + 150 => 8140865812151810389, + 151 => 6389103734850441969, + 152 => 2575842057131588226, + 153 => 594356232663542770, + 154 => 1831979486845532516, + 155 => 8593256573562561077, + 156 => 7880574155211524464, + 157 => 8805873656844352286, + 158 => 481952062150435744, + 159 => 5344682895583905652, + 160 => 4431795851344393081, + 161 => 200229955499138136, + 162 => 3446040485895609674, + 163 => 3819322718493431400, + 164 => 5570061082068382790, + 165 => 6195788367234023721, + 166 => 7737170449019800838, + 167 => 7189860243598930983, + 168 => 3695814792096072818, + 169 => 7328238707572705754, + 170 => 8237617790692775958, + 171 => 2421040057782286143, + 172 => 9123731997216590839, + 173 => 7870368877570322718, + 174 => 6746685907972137521, + 175 => 3279514073699994337, + 176 => 8146907585001569028, + 177 => 8005509624217800726, + 178 => 8815389483183695556, + 179 => 989218427530280, + 180 => 152564241437934990, + 181 => 2896785002929917315, + 182 => 9180171371579760515, + 183 => 1372845638841872529, + 184 => 1543781446270751720, + 185 => 6996592145669023981, + 186 => 641297956174053174, + 187 => 6506843995151195829, + 188 => 4327285952472132915, + 189 => 93969735972048449, + 190 => 7146488780964173465, + 191 => 7325211315372232663, + 192 => 1379534660709295213, + 193 => 218627402318144783, + 194 => 7028797649991292009, + 195 => 2062993269036281196, + 196 => 2418132038671378216, + 197 => 4213877387145221537, + 198 => 2305168940227281904, + 199 => 5241490712289865843, + 200 => 7811670338373750850, + 201 => 3487352672597766352, + 202 => 3988786684642859704, + 203 => 7679556464322192501, + 204 => 3423087906690637747, + 205 => 374037923633083834, + 206 => 5115941471980615670, + 207 => 4162011999502555957, + 208 => 6689720747934438082, + 209 => 3490590009453130170, + 210 => 7753742994320951697, + 211 => 4328663994260082003, + 212 => 5189469662998074615, + 213 => 6098487532616876178, + 214 => 4263428743935104021, + 215 => 5752035554439869569, + 216 => 2046487595553805213, + 217 => 6759469196299600301, + 218 => 3520395880965099516, + 219 => 1797031482626446318, + 220 => 2501035143557801104, + 221 => 2298695359504368325, + 222 => 1403235154147887633, + 223 => 7114666667206509344, + 224 => 2355757421375417044, + 225 => 1176380311135848472, + 226 => 6135084173684365933, + 227 => 3807453618422183633, + 228 => 6159070540359679625, + 229 => 6085705587752179336, + 230 => 2816611925986764411, + 231 => 1855966027251583905, + 232 => 2047838767071227236, + 233 => 1106535906566990110, + 234 => 342606207664427643, + 235 => 314808270709372207, + 236 => 2125955369183813854, + 237 => 2106191208920530861, + 238 => 5763783123126730019, + 239 => 8232423890287653023, + 240 => 7191721594809962715, + 241 => 6654213501519217177, + 242 => 2863323511322875411, + 243 => 3348853475114463167, + 244 => 1808535245438804772, + 245 => 8628388895981858947, + 246 => 5181081666016945124, + 247 => 7538183941572330620, + 248 => 3218163413270356679, + 249 => 7376062198048849789, + 250 => 960194202571946854, + 251 => 6568149204134090705, + 252 => 8461968823864752875, + 253 => 7411766832467140243, + 254 => 3017086282645398103, + 255 => 2352948378706839348, + 256 => 4565589200014953928, + 257 => 3814887713403517305, + 258 => 3919352955073918181, + 259 => 686018792620055997, + 260 => 5565296471810550038, + 261 => 6891701127128121620, + 262 => 7356342262966328530, + 263 => 3518721246598139843, + 264 => 7352486269414926658, + 265 => 4351562711475403568, + 266 => 6653732947494303370, + 267 => 1745179048405914784, + 268 => 4008437910961505086, + 269 => 7595152702354894404, + 270 => 7621019847577229671, + 271 => 1748063996251974809, + 272 => 185409768771914249, + 273 => 6488562757649247334, + 274 => 3203001527256031902, + 275 => 3869239823473074094, + 276 => 7084369734833436373, + 277 => 8880982667273708253, + 278 => 8232461911856803510, + 279 => 1244622703757505286, + 280 => 7358449720063243255, + 281 => 6291175411148511503, + 282 => 4888875013405899988, + 283 => 7987271011415329990, + 284 => 6947487367229983958, + 285 => 859642169871976125, + 286 => 3038542491392051195, + 287 => 3803374588769175039, + 288 => 8896937700643125, + 289 => 5511551017300618398, + 290 => 6295519027032874223, + 291 => 3378343739330070484, + 292 => 3657056468327428486, + 293 => 4384414227986475105, + 294 => 5359516167784948052, + 295 => 1264866755672470516, + 296 => 9217968726819697310, + 297 => 4679267606532786999, + 298 => 4547737627236036654, + 299 => 1723615400113718935, + 300 => 2730929903969423343, + 301 => 7365001511829019958, + 302 => 2718849859866214204, + 303 => 6429811818173024312, + 304 => 2517604504547993254, + 305 => 8416589395102725693, + 306 => 2753538379982923087, + 307 => 8207507712198072436, + 308 => 8731971924968886709, + 309 => 1557945820470114159, + 310 => 3313878317197431003, + 311 => 6291975050415254123, + 312 => 8498340926509011457, + 313 => 1336691153309145367, + 314 => 921178615715593210, + 315 => 3796365529397439888, + 316 => 8993944091836231593, + 317 => 382830236215768313, + 318 => 1723980057654337409, + 319 => 5614893682368827996, + 320 => 804450608184971273, + 321 => 2917243327795953065, + 322 => 5627509226384306182, + 323 => 1855693736635937149, + 324 => 6381630022732487180, + 325 => 2256285600539114843, + 326 => 6275321292249466725, + 327 => 4481984441932964590, + 328 => 2402640565735530321, + 329 => 2607819136695228602, + 330 => 8351317157393624596, + 331 => 2544199720021936165, + 332 => 7758221333072790020, + 333 => 1811695069546558093, + 334 => 3049093945571735285, + 335 => 8731119610463328870, + 336 => 4667688923458681575, + 337 => 3720854499108339362, + 338 => 249598668313425369, + 339 => 5734850026648411310, + 340 => 3203724484005151011, + 341 => 2553022277934009130, + 342 => 590801032259773604, + 343 => 3084208129082613232, + 344 => 624513962330896118, + 345 => 35272440206759584, + 346 => 377861291654163562, + 347 => 3218540593966076810, + 348 => 848128793277303753, + 349 => 4799065530158866776, + 350 => 1989940768162245803, + 351 => 9146509445186038240, + 352 => 2464366590020426600, + 353 => 6273443018121659344, + 354 => 4853763712141902212, + 355 => 4057574136853970250, + 356 => 6101770180328710946, + 357 => 1243173801821349658, + 358 => 7266624479371264981, + 359 => 1272619690957712078, + 360 => 5837687083107334356, + 361 => 1970715075261145158, + 362 => 215599224954317746, + 363 => 5782445277054564005, + 364 => 5922914965360975753, + 365 => 5922357963120918181, + 366 => 7974720231105349932, + 367 => 3110134032453005097, + 368 => 3790422030091187770, + 369 => 5629196288245273420, + 370 => 8677746754143943136, + 371 => 1402665210604771239, + 372 => 1697635478691658887, + 373 => 1424441829796170592, + 374 => 6574643956725178171, + 375 => 8559133939567042847, + 376 => 3898601078582069473, + 377 => 5028372719626148386, + 378 => 2973513384510132122, + 379 => 1482239108716270737, + 380 => 6485432760880238821, + 381 => 6735352681169260889, + 382 => 8858168343448212954, + 383 => 3417172331102877774, + 384 => 6610375869138620919, + 385 => 9094809473664691904, + 386 => 1021650463606714753, + 387 => 6993423997015986991, + 388 => 1453180291441036225, + 389 => 7530286108414768065, + 390 => 5110730809219713506, + 391 => 5365329825124599577, + 392 => 8634418988317791053, + 393 => 4006150892716966837, + 394 => 4511401999516051326, + 395 => 6143969098971950610, + 396 => 5812144812301555992, + 397 => 1200926849729513567, + 398 => 3263634571539849108, + 399 => 5857979258822948839, + 400 => 8475871787874177845, + 401 => 841786866461386162, + 402 => 655616888581538746, + 403 => 3815816305286008330, + 404 => 1988938720157771750, + 405 => 4793373822153701438, + 406 => 5151382658359052481, + 407 => 4369112825585669113, + 408 => 1991068901321222716, + 409 => 2208433930863023846, + 410 => 1999057519324727338, + 411 => 6047676286569859324, + 412 => 7806601671634708796, + 413 => 8582019256874037354, + 414 => 7381515526205666046, + 415 => 6278587726803058936, + 416 => 1911608077162658271, + 417 => 6840603580451723447, + 418 => 6427810289814326744, + 419 => 3521109705634284210, + 420 => 7840964958776459408, + 421 => 4870965888046740992, + 422 => 8236554901305785610, + 423 => 7568324374489985438, + 424 => 2108265637973224396, + 425 => 7568920152398252943, + 426 => 1278003570172216654, + 427 => 4449977212013112508, + 428 => 1372535111262263176, + 429 => 4134782838961700211, + 430 => 6142364290597977673, + 431 => 7277539595398623516, + 432 => 6106063809768454688, + 433 => 6562543799407154245, + 434 => 8189650266221078133, + 435 => 1306723926360669015, + 436 => 1361094140696478141, + 437 => 3006181407776645476, + 438 => 293984137646838342, + 439 => 6343493076687660691, + 440 => 7053389705627094905, + 441 => 3228267070781127927, + 442 => 5681667327836315888, + 443 => 8840600809098820382, + 444 => 2684486535605392551, + 445 => 6333490941785691512, + 446 => 389486682851617180, + 447 => 576494266880790394, + 448 => 7511502181867260082, + 449 => 4027093556455566701, + 450 => 3616193044317152004, + 451 => 3049686564119237752, + 452 => 4221157671305548160, + 453 => 7704763627016187142, + 454 => 4305183058388395883, + 455 => 3885677445033742256, + 456 => 5265176269292016228, + 457 => 6816588084279622366, + 458 => 508054728620040721, + 459 => 5757050308131621621, + 460 => 5728270465762896089, + 461 => 10242882944417823, + 462 => 5560711064529460247, + 463 => 370645014767162790, + 464 => 5402593535206520838, + 465 => 4135570265663024907, + 466 => 3262585839223129550, + 467 => 8610250528166978661, + 468 => 2465000875618311903, + 469 => 2594528855337781101, + 470 => 4656935565401743143, + 471 => 5965733432054092680, + 472 => 8951959858208817856, + 473 => 330892896908269457, + 474 => 3903329834507850427, + 475 => 5426221231541544352, + 476 => 6748762318436301312, + 477 => 1618803931080719107, + 478 => 4708889135714290650, + 479 => 4614310932372952069, + 480 => 8234328039947133334, + 481 => 3529624962059772425, + 482 => 6113839833259725039, + 483 => 431760469825089652, + 484 => 6928811856011191471, + 485 => 3401443979195041874, + 486 => 8744020780038361839, + 487 => 3202587343066132369, + 488 => 6307801402874043843, + 489 => 7605914291768823537, + 490 => 4484892283389238181, + 491 => 9077420194924607498, + 492 => 5569201505520289171, + 493 => 7006302488541034835, + 494 => 6313552156392160207, + 495 => 8600021738367428410, + 496 => 8760224779819629581, + 497 => 9132163291178769644, + 498 => 1163578039792756164, + 499 => 9007550877294579854, + 500 => 2113126666210207858, + 501 => 1716067612083947306, + 502 => 4696646431096805784, + 503 => 4892977485522978230, + 504 => 2606886878829279424, + 505 => 2860735242327403740, + 506 => 2858178867738426477, + 507 => 2457003835651906640, + 508 => 5473436253484533684, + 509 => 2002711098304871944, + 510 => 3711327314728309895, + 511 => 2661507646727242860, + 512 => 1603398505746741019, + 513 => 2081839847326618075, + 514 => 9118607592277830944, + 515 => 4003417104304718975, + 516 => 7638697782989141632, + 517 => 5280498865969228879, + 518 => 6012718792771796529, + 519 => 6730646540258665633, + 520 => 3608954646784694876, + 521 => 3623516597422952924, + 522 => 7927960790090716608, + 523 => 7471112208973670906, + 524 => 7715755484650362651, + 525 => 1733882614021894178, + 526 => 3316694596547763218, + 527 => 4445517620991034265, + 528 => 8910447438379036694, + 529 => 5195647047845410702, + 530 => 7632385228145598814, + 531 => 701968830990199555, + 532 => 5101797093602684451, + 533 => 5053858722493468795, + 534 => 8351243130017152811, + 535 => 3407931510912811624, + 536 => 8311758292679424567, + 537 => 1297092285993765528, + 538 => 914716191141690367, + 539 => 8976031287153009917, + 540 => 8688831725087172751, + 541 => 5450523643582409441, + 542 => 479226731116004241, + 543 => 462567726357113156, + 544 => 2993926602253302616, + 545 => 3465679830643125269, + 546 => 7048033484763006199, + 547 => 7925328552854417920, + 548 => 5033270455573018001, + 549 => 2987035035882169517, + 550 => 3742981512483447158, + 551 => 1011506677036260263, + 552 => 1266288907222028636, + 553 => 6874999726492777014, + 554 => 8083506553440899572, + 555 => 2388755111425388483, + 556 => 6323559231790345913, + 557 => 3312218772276387388, + 558 => 55498136977302553, + 559 => 7020654216607691005, + 560 => 3818682513350450085, + 561 => 3079609942405098075, + 562 => 2564494752829926622, + 563 => 5464978521027843435, + 564 => 2998524196941901843, + 565 => 8640504199330679825, + 566 => 885286653896253519, + 567 => 8146965280491617339, + 568 => 5239038900310123713, + 569 => 571143241474831846, + 570 => 8070345949082810486, + 571 => 2073900721119019816, + 572 => 7373009383449635473, + 573 => 7395991325064669920, + 574 => 267058295875050713, + 575 => 5783967400531846816, + 576 => 5576812800692668857, + 577 => 721337116599480577, + 578 => 7129238316609114797, + 579 => 1321862547889470362, + 580 => 4276735618469428853, + 581 => 895687918794586060, + 582 => 5255977436524353487, + 583 => 3724092850406415996, + 584 => 5410233682098235628, + 585 => 6905597463607452084, + 586 => 8205239358756889146, + 587 => 3499256513479295822, + 588 => 2697248429010720092, + 589 => 4697373330191096026, + 590 => 4914338059158230267, + 591 => 972342800985503716, + 592 => 423731006815772013, + 593 => 5736874206917961117, + 594 => 7585715450588204355, + 595 => 507871806599117628, + 596 => 7360005929733977730, + 597 => 2252761756389000328, + 598 => 7411327568258861019, + 599 => 2750179567721440696, + 600 => 4309813956486140650, + 601 => 8603742742444436939, + 602 => 8391025282022120530, + 603 => 1198371700832342608, + 604 => 4883754287481231729, + 605 => 5710796305107174751, + 606 => 5761058551728636463, + 607 => 5965758509720381072, + 608 => 3062864866766847482, + 609 => 1053515136296232189, + 610 => 5267509176967170196, + 611 => 2785379797710845019, + 612 => 1784774168376930270, + 613 => 5208490639137887703, + 614 => 5630708637418765877, + 615 => 418093454333836730, + 616 => 9088486131581099071, + 617 => 956713060251000167, + 618 => 3743742244873999245, + 619 => 6138699062987301859, + 620 => 1817115382564979038, + 621 => 2230031154253235473, + 622 => 5747751380213441530, + 623 => 7367060978087636475, + 624 => 5023383821093726397, + 625 => 1822421796459299694, + 626 => 7232246515575623797, + 627 => 7510903819509944073, + 628 => 6556793836922699434, + 629 => 8707257399915605054, + 630 => 7885499740413820738, + 631 => 8887422760609964591, + 632 => 4285540165956757506, + 633 => 4473291544005766784, + 634 => 5409219398962529776, + 635 => 8688313864932357095, + 636 => 3433706849989809089, + 637 => 5517810801190806704, + 638 => 5659574505620033072, + 639 => 5165679738957564467, + 640 => 1093134237377948709, + 641 => 3716207738176709909, + 642 => 2042966407030502826, + 643 => 7270587694808708742, + 644 => 7046542270185199463, + 645 => 1608353243977058066, + 646 => 6676372799431348410, + 647 => 8527580547930000977, + 648 => 4389725112462558468, + 649 => 8420375003325446462, + 650 => 4034505531541849631, + 651 => 607456153282715867, + 652 => 3354592612015213217, + 653 => 1747357473885226463, + 654 => 1368126747799482046, + 655 => 1946875072443724961, + 656 => 8112505106805386743, + 657 => 7542376547484468493, + 658 => 5825146822885048586, + 659 => 8810925825577002448, + 660 => 1098045191592657671, + 661 => 5554980522695945700, + 662 => 3056852788358290126, + 663 => 7577282937056099199, + 664 => 6085476975669385795, + 665 => 3897530094796435421, + 666 => 6604699103610917202, + 667 => 1985689462969122284, + 668 => 155255881360087381, + 669 => 2589283086881204308, + 670 => 5549897452281504715, + 671 => 4247878561482139399, + 672 => 6554744406886456845, + 673 => 1518866713136502592, + 674 => 8672147039215763956, + 675 => 8812455771110880190, + 676 => 9045645245053108040, + 677 => 542610261043875178, + 678 => 6828709344824601833, + 679 => 5540037647282053318, + 680 => 820449658946289950, + 681 => 9125060583638159848, + 682 => 5062176721782453146, + 683 => 6220868436477704059, + 684 => 6685957526481370221, + 685 => 5243435857380984648, + 686 => 4865216808948245474, + 687 => 1390450459486865132, + 688 => 2216233338560013215, + 689 => 3713157070016975060, + 690 => 625688638163345435, + 691 => 6994866079644296276, + 692 => 3160776741644770252, + 693 => 9128729553660341149, + 694 => 8195530447799999593, + 695 => 8656514976704884913, + 696 => 6817001557060663265, + 697 => 248540713099472524, + 698 => 3526979572554748152, + 699 => 97088824400894088, + 700 => 601659643808425857, + 701 => 6284738358644049982, + 702 => 9100327408937925020, + 703 => 6145077406766620372, + 704 => 3828649506412304998, + 705 => 379640483070970424, + 706 => 8248340428823391634, + 707 => 6518959188733605565, + 708 => 4417066651702603697, + 709 => 1988674242668141989, + 710 => 754158859435039205, + 711 => 6209194427676368108, + 712 => 9175218526932911363, + 713 => 5474369419395785884, + 714 => 7749315319490631170, + 715 => 1410973525894440677, + 716 => 8080979716285596339, + 717 => 5025221410341821345, + 718 => 9072498667061025880, + 719 => 6785654549699541834, + 720 => 858540981310046047, + 721 => 2695290815150217356, + 722 => 2518424807051291104, + 723 => 656394352807450747, + 724 => 6272104156501301664, + 725 => 2072704408203714543, + 726 => 5086687192151004543, + 727 => 7099619962543493003, + 728 => 1952754063856361647, + 729 => 2700497621179782827, + 730 => 3287369282844261933, + 731 => 8820933188221033763, + 732 => 6089674773043703315, + 733 => 8766929537890083041, + 734 => 893445846482184430, + 735 => 2439826153646459665, + 736 => 2510030032630370075, + 737 => 7702319715824368918, + 738 => 7497239997853368349, + 739 => 2709311660016292931, + 740 => 5992516434162601935, + 741 => 3882990162899065825, + 742 => 688540185549553848, + 743 => 6814290476765634139, + 744 => 5399085729685899333, + 745 => 3179025140944384479, + 746 => 2379659294460850588, + 747 => 2691546279673217462, + 748 => 7099510012909814850, + 749 => 3913619154454952962, + 750 => 2661605413514255404, + 751 => 2436645158151043937, + 752 => 2554126393441293259, + 753 => 7769362866180288129, + 754 => 1564489520316059441, + 755 => 2325088747476948805, + 756 => 5459085167609703965, + 757 => 8996105578294155171, + 758 => 38103186160584530, + 759 => 2213757983679234165, + 760 => 6700928310691780276, + 761 => 2312525577541061088, + 762 => 8468514043278754635, + 763 => 4686874084401232704, + 764 => 4635040283394937732, + 765 => 6569843528290682716, + 766 => 5900818546597043188, + 767 => 2622229021259009500, + 768 => 90235205733376455, + 769 => 5485504287827578997, + 770 => 7756994071892432653, + 771 => 4488002925571905259, + 772 => 7201564045954032054, + 773 => 3804962472225188269, + 774 => 3503087998022261166, + 775 => 8286697161849556198, + 776 => 8270838661570273868, + 777 => 6644948367277401245, + 778 => 2627293613646575595, + 779 => 3135016409118404512, + 780 => 2630238474927749691, + 781 => 7190640386888177408, + 782 => 42177282811802881, + 783 => 781104983174926670, + 784 => 4070802246278330748, + 785 => 2315687309242593831, + 786 => 8355199924965167798, + 787 => 8124708651467360151, + 788 => 6608734050418144232, + 789 => 2201400413120338274, + 790 => 8534302486482543969, + 791 => 8943151629929900358, + 792 => 5333313547436428055, + 793 => 2481341862355030416, + 794 => 2775399824708278150, + 795 => 5767672141270076287, + 796 => 7192792032637061939, + 797 => 3883993140058451309, + 798 => 6059568370744519100, + 799 => 3907204139030102003, + 800 => 3244098500688195689, + 801 => 5761179579113480153, + 802 => 7484751102625204501, + 803 => 4553745840001581034, + 804 => 490228445509277896, + 805 => 4456127567802202210, + 806 => 4654428128679372758, + 807 => 4029855497207113748, + 808 => 3468132840184044524, + 809 => 7174658501796474845, + 810 => 923053899218921654, + 811 => 151995938145576336, + 812 => 7216144945415001910, + 813 => 7869000134779630870, + 814 => 2063284531981161558, + 815 => 5782340072335062339, + 816 => 596478139869983134, + 817 => 2203655457759318283, + 818 => 4240657808847284861, + 819 => 6112167885655631405, + 820 => 2007943018539275218, + 821 => 4334496102316359087, + 822 => 9023141725107317752, + 823 => 4732085520578299813, + 824 => 4336196076136431865, + 825 => 6144066483553094530, + 826 => 4807410324698512202, + 827 => 2372888701029832401, + 828 => 7601607246128249312, + 829 => 1187833186492304472, + 830 => 1585901443452685703, + 831 => 1613277765726700376, + 832 => 3522779823866277040, + 833 => 937032336848323540, + 834 => 3595239155163222018, + 835 => 7470142027646456994, + 836 => 3262784430640560426, + 837 => 8084449840845917640, + 838 => 8843667871242080269, + 839 => 7735904326673704177, + 840 => 1061106347922772246, + 841 => 5187332017133848929, + 842 => 1000164134418527195, + 843 => 8078460278521778055, + 844 => 3228252292902801263, + 845 => 8279960205575532529, + 846 => 1145334284751282312, + 847 => 5883236953711303071, + 848 => 8047624102443190426, + 849 => 9828087041298750, + 850 => 2810544506488476207, + 851 => 265860665779719660, + 852 => 5070359708370748610, + 853 => 1615855335579069785, + 854 => 5442024965361964816, + 855 => 47229328765426626, + 856 => 2601200962846792374, + 857 => 7007898913684144110, + 858 => 8042273211806353089, + 859 => 4661688036597295036, + 860 => 4461757026146852136, + 861 => 440491809802475584, + 862 => 6924953076807098266, + 863 => 7667705637749029212, + 864 => 7987752408360234701, + 865 => 7625717783840245866, + 866 => 4607814363128687241, + 867 => 80852347904676659, + 868 => 3146959882398918286, + 869 => 6826428485131082134, + 870 => 8400537846840027180, + 871 => 2711284394982515205, + 872 => 1722070780082535966, + 873 => 8155461978340045245, + 874 => 3542400106006264555, + 875 => 5689955191076126596, + 876 => 5506128256509180261, + 877 => 2981921812207554348, + 878 => 5903295504738479656, + 879 => 4137518131170515679, + 880 => 6442156129089494781, + 881 => 1493611821682800228, + 882 => 1801860501149702924, + 883 => 4452970223759356633, + 884 => 4612263936100636690, + 885 => 7084419826676148394, + 886 => 1778820814512868119, + 887 => 9151147101753888246, + 888 => 3000359123829248981, + 889 => 7802977045337713535, + 890 => 7546029112468137968, + 891 => 8361650625114482351, + 892 => 6820184984670713500, + 893 => 2920678429698178088, + 894 => 254178646271857800, + 895 => 5193114900049568672, + 896 => 8823757443723650857, + 897 => 1438924614747268975, + 898 => 6988868848594969528, + 899 => 381321064343674387, + 900 => 1794394587837725985, + 901 => 4798517106923699475, + 902 => 4287925013205250136, + 903 => 7281941390084614886, + 904 => 1181130840268681361, + 905 => 8231078563299312081, + 906 => 1626929942370015261, + 907 => 4011066397059515411, + 908 => 1377541762324212889, + 909 => 6352731916678563899, + 910 => 7507858022928484551, + 911 => 1775957163982344360, + 912 => 5332390995674094149, + 913 => 6648820569792235163, + 914 => 4382323655636206913, + 915 => 2416072885601967248, + 916 => 6771148913251765702, + 917 => 3220865591870905463, + 918 => 6193166166639477765, + 919 => 507823696432210896, + 920 => 8273784248128462808, + 921 => 4811327358074545583, + 922 => 2538484591145445792, + 923 => 7779920779031048201, + 924 => 4081098023353380063, + 925 => 6172740703937445717, + 926 => 9155549786310093952, + 927 => 7864483879343860268, + 928 => 8610461640989310915, + 929 => 7951726263097638561, + 930 => 618421656059113701, + 931 => 2691518317397463368, + 932 => 1810817030560116306, + 933 => 3790904087943543880, + 934 => 3866280676985654218, + 935 => 8838458242293900628, + 936 => 8523152465085084560, + 937 => 9072745839689098254, + 938 => 3517170062857140778, + 939 => 8892136170201531930, + 940 => 5444695900560096752, + 941 => 4621515270503315734, + 942 => 2601886078043236751, + 943 => 1497562977561528518, + 944 => 4139334289846219916, + 945 => 3203251948907624275, + 946 => 4831715581746647576, + 947 => 5015943809269656466, + 948 => 99512611546663110, + 949 => 2735247500080506080, + 950 => 1552115259394227766, + 951 => 8840678802505642128, + 952 => 2180697725105299577, + 953 => 7679889840900159976, + 954 => 6527889815296673480, + 955 => 5171165293993864453, + 956 => 6466672224429766686, + 957 => 1955394190900503131, + 958 => 6373715509169650325, + 959 => 5733301580524984567, + 960 => 6617301940566165317, + 961 => 1408383692984324522, + 962 => 869333895019300080, + 963 => 8773128040023542138, + 964 => 3725762730236575829, + 965 => 5934545856041902504, + 966 => 8858971006759069304, + 967 => 7722890130348813871, + 968 => 1204883589769914961, + 969 => 4620672877536160644, + 970 => 1676092823582414034, + 971 => 464643714852702111, + 972 => 8255541161658975010, + 973 => 2453757805726767821, + 974 => 495881574127521317, + 975 => 4605661336961390615, + 976 => 7195255126092134055, + 977 => 5136938396092820125, + 978 => 1245648619692976063, + 979 => 3583987811290822651, + 980 => 2376615459075945494, + 981 => 4863711049267980295, + 982 => 8325669006165324519, + 983 => 7868585605317695160, + 984 => 7718332277705538201, + 985 => 1991127768292105199, + 986 => 1231779673761743898, + 987 => 1109036875016310371, + 988 => 8066986049072645316, + 989 => 738131723952888174, + 990 => 3591709815076139806, + 991 => 1676981783546208868, + 992 => 3792219845932686047, + 993 => 7686603600193132171, + 994 => 9024591363567483879, + 995 => 39193345711209503, + 996 => 5163764060302020998, + 997 => 6933944874400891179, + 998 => 3597528434156690701, + 999 => 2846380545071499345, ); $rng = new \RNG\MT19937(SEED); foreach ($result as $ret) { - $rng_next = $rng->next64(); + $rng_next = \rng_next64($rng); if ($ret !== $rng_next) { die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); } diff --git a/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt b/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt index aa32fc935ac33..3a40611b6a8a0 100644 --- a/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt +++ b/ext/standard/tests/rng/mt19937_unserialize_unexcepted.phpt @@ -3,7 +3,7 @@ Test class: MT19937: unexcepted __unserialize(). --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/rng/xorshift128plus_result.phpt b/ext/standard/tests/rng/xorshift128plus_result.phpt index c3ba52f62007e..a82980c929584 100644 --- a/ext/standard/tests/rng/xorshift128plus_result.phpt +++ b/ext/standard/tests/rng/xorshift128plus_result.phpt @@ -3,7 +3,7 @@ Test class: XorShift128Plus: consistent result. --FILE-- 1349682502, 1 => 2037461237, @@ -1009,7 +1009,7 @@ $result = array ( $rng = new \RNG\XorShift128Plus(SEED); foreach ($result as $ret) { - $rng_next = rng_rand($rng); + $rng_next = \rng_next($rng); if ($ret !== $rng_next) { die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); } diff --git a/ext/standard/tests/rng/xorshift128plus_result_64.phpt b/ext/standard/tests/rng/xorshift128plus_result_64.phpt index 77c44cc09f358..86ee2f701831b 100644 --- a/ext/standard/tests/rng/xorshift128plus_result_64.phpt +++ b/ext/standard/tests/rng/xorshift128plus_result_64.phpt @@ -9,1013 +9,1013 @@ if (PHP_INT_SIZE < 8) { --FILE-- next64(); } var_export($arr);' +// ./sapi/cli/php -r '$r = new \RNG\XorShift128Plus(12345); $a = []; for ($i = 0; $i < 1000; $i++) { $a[] = rng_next64($r); } var_export($a);' $result = array ( - 0 => 6233086606872742541, - 1 => 8068093359486558699, - 2 => -5167171210566177746, - 3 => 7067430833834273300, - 4 => 5869501872498816438, - 5 => 8546184145333981366, - 6 => -7675341174649472037, - 7 => -5438916696891469318, - 8 => 805546558303401653, - 9 => -1549078639761564387, - 10 => -7947959769147200545, - 11 => 4238051778512541505, - 12 => -3355517432467612811, - 13 => 2534162508875358333, - 14 => -5169366708103015627, - 15 => 7622337846211186667, - 16 => -2843892751838703475, - 17 => -9169669279398039191, - 18 => 6672454254697035728, - 19 => 980861210597187832, - 20 => -2947025856922216306, - 21 => -2876937829800049194, - 22 => 5378361677646670264, - 23 => 6402376320460634810, - 24 => -3112745002104049525, - 25 => 7815704014450658747, - 26 => 1362205306649980894, - 27 => 1968397761034373619, - 28 => -3884701032555926147, - 29 => 9035062408836807463, - 30 => 3735692176783396855, - 31 => 238903888548784095, - 32 => -1547687286147527232, - 33 => -327747487918073720, - 34 => -4957213332539273623, - 35 => -8987780780324084884, - 36 => 7279061022635620231, - 37 => 6833462932152176756, - 38 => 4549426172800087769, - 39 => -4973794557781727597, - 40 => -526506095019231282, - 41 => 2235751933618072853, - 42 => 7858298588449505503, - 43 => -8584081284247293923, - 44 => -7887380617646453290, - 45 => -801559887372628839, - 46 => -3617803946929849252, - 47 => -7967077348488522463, - 48 => 9193227545043564129, - 49 => 4108913838247458545, - 50 => -2343931640686067394, - 51 => 3663807406097505734, - 52 => -7023588444321952761, - 53 => 4145043411097895175, - 54 => 6607570033444447885, - 55 => -6885783092079794279, - 56 => 5613946615107134069, - 57 => 1042743975275329464, - 58 => -8880377862898686283, - 59 => -8664205809451843946, - 60 => 3894109949614687885, - 61 => 3511737541150869129, - 62 => 6400129353949170872, - 63 => 6965486229827646802, - 64 => -1614484618550933281, - 65 => 1486137421109900574, - 66 => -6584711946535572634, - 67 => -4130422719320539545, - 68 => -847253235650814396, - 69 => 8903455639056950966, - 70 => 7024659691941650728, - 71 => -4118196956427743125, - 72 => -3234872081255157887, - 73 => -3164660236169804854, - 74 => 7422910021644831697, - 75 => 8771490394997018825, - 76 => 6798485190349206224, - 77 => -2028541901030213841, - 78 => -6453336362726229052, - 79 => -4778723017089571418, - 80 => -5798499399712631463, - 81 => 5731049845555933611, - 82 => 6662887178192577197, - 83 => -3388473494806557889, - 84 => -5139491467951936257, - 85 => -5038018771103928001, - 86 => 2158430451305515027, - 87 => -3688233498091126328, - 88 => -8792995464287168000, - 89 => 1359803583268476033, - 90 => -6052703011673051588, - 91 => -976225281502684492, - 92 => -3185708908479278470, - 93 => -16113752611901372, - 94 => -2572201364453856038, - 95 => -7864440779878722603, - 96 => -294441446441315108, - 97 => 414333712007741859, - 98 => -7930716040860241460, - 99 => 8619013226169796028, - 100 => -4202414296431584036, - 101 => -2343016349138864644, - 102 => -2044263328869969367, - 103 => 8089952478337103652, - 104 => -585397951647681395, - 105 => 2036354567926795127, - 106 => -3629057568451149623, - 107 => -620120117439951175, - 108 => -8006071254949715577, - 109 => -7273790937381774969, - 110 => -2681075441755554641, - 111 => 1844472049624527208, - 112 => 5055321696745578140, - 113 => -953286305830419985, - 114 => -7896578919851440390, - 115 => -5942918302882234964, - 116 => -3633818902942828948, - 117 => 6133200497452107780, - 118 => -103538567329975006, - 119 => -2533939224349090, - 120 => -1424892818446275911, - 121 => 4370577474642180257, - 122 => 1189510330126649032, - 123 => 8312511900242964775, - 124 => 1672650990389528209, - 125 => -2392028076118911657, - 126 => 7594315045759083481, - 127 => 2014190143424401968, - 128 => -3296960212478198676, - 129 => -7889768735440771399, - 130 => -3214911664057091864, - 131 => -3315075499741726696, - 132 => -5937641061220953635, - 133 => -8409365331808720382, - 134 => -8098312379770620366, - 135 => -6997572329348870486, - 136 => -1505822663309332265, - 137 => -3211177253496784362, - 138 => 897815089124755184, - 139 => -7431939192649083944, - 140 => -7649604383115863939, - 141 => -3096433820968260974, - 142 => -6503366919701300580, - 143 => -4910219149257086447, - 144 => -898559130062898943, - 145 => 6181990163088110987, - 146 => 153062574018015307, - 147 => -3402824860217828895, - 148 => -5128512071825492999, - 149 => 9194357913130180980, - 150 => 960481574545876949, - 151 => 8374922126864673287, - 152 => -2966485336578683811, - 153 => 222603101549412370, - 154 => -8392610021687956103, - 155 => 4608733847218068155, - 156 => -2152136474932976790, - 157 => 2312268905607092057, - 158 => -2932732821033080541, - 159 => -2595244369435982912, - 160 => -8859418541246010991, - 161 => 2987843757009406049, - 162 => -8263775768403446591, - 163 => 7956517580982604885, - 164 => -4855086198396263825, - 165 => -508357658904446476, - 166 => -3866150645688483983, - 167 => 9152901218921465745, - 168 => 8897302951662108151, - 169 => 7287054514503404883, - 170 => -2722862352960184650, - 171 => -5343479560489618196, - 172 => 7807084719929503224, - 173 => 7300647471747593999, - 174 => 2684475586745085484, - 175 => -1325083438655837283, - 176 => -3192540574639490056, - 177 => -5097580822155334733, - 178 => -3835928535232602010, - 179 => -819597750488737491, - 180 => -4256127033789079489, - 181 => 4230186832109259838, - 182 => -301086512678485577, - 183 => -9141693794819060088, - 184 => -3701409747403958874, - 185 => 4004433656181874604, - 186 => 4662227143243807153, - 187 => 8265173367459193111, - 188 => -6872268542664552850, - 189 => -368254286513810841, - 190 => 5260534621686705801, - 191 => 6641868644832940139, - 192 => 2768722268492316825, - 193 => -5681941453701006152, - 194 => 7900162273330097180, - 195 => -3935494402550361757, - 196 => -297196673737786987, - 197 => -2218494427935798109, - 198 => -8585051849471202107, - 199 => 1189254491034925451, - 200 => 305201422294193849, - 201 => -7334571942792835247, - 202 => 2967579379284875785, - 203 => -3764933945431408081, - 204 => 6807938953141792641, - 205 => 6042179712895521060, - 206 => -4687158022512797000, - 207 => -5582265326438641183, - 208 => 4522899856350395734, - 209 => 7669896904145453755, - 210 => -6684219449507768914, - 211 => -676763327750723841, - 212 => 2879997055424213598, - 213 => -2664579015401502506, - 214 => -6102005420377100548, - 215 => -8083997683709524572, - 216 => 1215494657986916139, - 217 => -1972053395263624114, - 218 => -3352733695972692415, - 219 => -2749431011073787488, - 220 => 5156465409506471832, - 221 => -837693036075046523, - 222 => -6445889520869578857, - 223 => 2403718291494117273, - 224 => 7290825940407324119, - 225 => -3797103220415147685, - 226 => 1913161382212324391, - 227 => -5250288546821294161, - 228 => 801489540680920193, - 229 => 55816928350842307, - 230 => -5189097228641397087, - 231 => -7418994264930652941, - 232 => 3111998697246278141, - 233 => -7658555071646748793, - 234 => 2443258963310405618, - 235 => -1455653740850447211, - 236 => 6462754302499731382, - 237 => -7390965621123671206, - 238 => 2059181699507065984, - 239 => -7830135668617385061, - 240 => 551861004603649367, - 241 => -28505787185237769, - 242 => -6111755252645739296, - 243 => -2786692911721332024, - 244 => -5431530429075754767, - 245 => 3859506090475293804, - 246 => -607806511712055592, - 247 => -1604928790975109348, - 248 => -6919237020917052398, - 249 => 1659823400194974898, - 250 => 3260109291172110587, - 251 => 7103660588537229825, - 252 => 2868540883423402698, - 253 => -6973595968574399656, - 254 => -3010740476117536316, - 255 => 5791607569770570048, - 256 => -4839982369050771366, - 257 => -7326197626644746063, - 258 => -5760564212305582148, - 259 => 8245851483814498739, - 260 => -1261608103078589172, - 261 => 6872989402933107904, - 262 => 6926902352662665902, - 263 => 375124288680082211, - 264 => 3086545633031909538, - 265 => -6386804902164786029, - 266 => -1242790247806959997, - 267 => -1681430887095756027, - 268 => 5137372031839899489, - 269 => 2754788085284731462, - 270 => 6325822581971560136, - 271 => -8444821628536905566, - 272 => 2475558550482960736, - 273 => 6516139044969237568, - 274 => 6065815787485755018, - 275 => -2337634903387833087, - 276 => -6565883552260127024, - 277 => 9062653444256330533, - 278 => 4131468415902220, - 279 => -2804413712969716005, - 280 => 2317396077435523547, - 281 => -4970445540823094516, - 282 => 6420315594566913890, - 283 => -5922403123810491315, - 284 => -2808452863210499590, - 285 => 617483705407310346, - 286 => -6228542687770337922, - 287 => -1113468420487711679, - 288 => 8828681624504014775, - 289 => 6287274941865377114, - 290 => 5117868422945902333, - 291 => 1287551252614211749, - 292 => -1173498864336099974, - 293 => 5036837401203653996, - 294 => -2606254505571119214, - 295 => 3423852390119064549, - 296 => -9000591993750676812, - 297 => -8867631436364331574, - 298 => 6767524122168251427, - 299 => 162839175744794974, - 300 => -528555657111943786, - 301 => 2101582834726902697, - 302 => -317338495447985567, - 303 => -5648554254600403004, - 304 => 5564803131766712968, - 305 => -5252930376543610873, - 306 => 56271831026699195, - 307 => 8844442151310258591, - 308 => -1230301930879619982, - 309 => -6256187407793446292, - 310 => 4807718328804520520, - 311 => -5863940751946617339, - 312 => 6905938723205835745, - 313 => 4075335344864414281, - 314 => 3433531159208347315, - 315 => -2069840850591842763, - 316 => 7516036388331324446, - 317 => -2592397801079222232, - 318 => -8126100301504316342, - 319 => -7273022652949339827, - 320 => 7338189214894710364, - 321 => -9049129361743244256, - 322 => -569994482749250953, - 323 => 1999871819672998377, - 324 => -6983736397764704713, - 325 => -3071713744516734676, - 326 => -8071837264363519337, - 327 => 748694073946532348, - 328 => -3330632703556046290, - 329 => -1124594114902335244, - 330 => 2526761214268222568, - 331 => -1657220373902169273, - 332 => 371555305382119287, - 333 => -6368460380663182397, - 334 => 5727708374322006369, - 335 => 3383625716635606776, - 336 => 1490509743458220363, - 337 => -5823012005238396473, - 338 => 2657402502686094353, - 339 => 2523072086880676074, - 340 => -5212150126378343972, - 341 => 3263546208638625941, - 342 => -8842197938699360653, - 343 => 6374843986142087000, - 344 => 4220080406234818700, - 345 => -230832620073276369, - 346 => 6840381043077099619, - 347 => -1613588878580426717, - 348 => 3390573976942207403, - 349 => 430050069716772959, - 350 => 4962800447006999936, - 351 => 2185947515463616467, - 352 => 4271389234446298896, - 353 => -5340519306352117744, - 354 => 1197203261499495306, - 355 => 6677131389043771525, - 356 => 5546711611730970947, - 357 => -6529594906300554712, - 358 => -5989672402410720514, - 359 => 1153906435455000794, - 360 => -6056925494745450161, - 361 => 4199404349532119493, - 362 => 6557837025617915863, - 363 => 2556671403775761341, - 364 => -4544597408257187481, - 365 => 814880520407626678, - 366 => -5852348228132151619, - 367 => 6492249149631356053, - 368 => -3177829576285382316, - 369 => 4864154138545570939, - 370 => -8677430544928980841, - 371 => 8749511087731377965, - 372 => -9152552649319357740, - 373 => 402896885114503720, - 374 => -7491531018035586066, - 375 => 6355574295691978853, - 376 => -2704974177237563067, - 377 => 1165814196029775407, - 378 => 3208728433494425336, - 379 => 1429392515143905195, - 380 => 2380441736978229060, - 381 => -6658299069287454659, - 382 => 4109416891616055006, - 383 => -5146082782977310060, - 384 => -1278045846500555482, - 385 => -4765004337146065901, - 386 => -4262098568510576231, - 387 => 1086271076349384072, - 388 => 5650601861900182068, - 389 => -2632384338904542913, - 390 => 6381088846802079525, - 391 => 5513341014011794810, - 392 => 3835165564590331379, - 393 => -6274557285119588118, - 394 => -30989483748122322, - 395 => -7017532806115885258, - 396 => 4383771638185842327, - 397 => 1544994207802977422, - 398 => 6628347564412562227, - 399 => 4675575756843593136, - 400 => 6877298263631656980, - 401 => 8188015606131763609, - 402 => -5798386943811896584, - 403 => -6773161803381332958, - 404 => -3661002970975771146, - 405 => 5643851515130170925, - 406 => -6200679549515097687, - 407 => -2538924580828788363, - 408 => 6125484710344506788, - 409 => 4417758651294828199, - 410 => -529498194253919357, - 411 => -6349934711223662455, - 412 => -4133451028214498258, - 413 => 2659634268627517050, - 414 => -458638004142023708, - 415 => 3600950078580554951, - 416 => -4701618839941594073, - 417 => 607344099330032742, - 418 => -2851435838091702918, - 419 => -1485062284045911889, - 420 => 1805718222250101604, - 421 => -3086433846926675995, - 422 => 3055925737213207767, - 423 => 7918979740159439390, - 424 => 2899418100314977091, - 425 => -5832127953693127691, - 426 => 1843869831041188589, - 427 => -5473289788120622366, - 428 => -8201178903628152904, - 429 => -2115228561554159419, - 430 => -389224390707379122, - 431 => -9093559932117923740, - 432 => 5415491869480049272, - 433 => -8834861133961889021, - 434 => -6614115603878181597, - 435 => -3507458754926709108, - 436 => -7229539372363003824, - 437 => -6527827874523834853, - 438 => 3202286537820120427, - 439 => 1295397612851020484, - 440 => -5043151425327244028, - 441 => 5615542153522392944, - 442 => -3302134258426565077, - 443 => 8459571853036894401, - 444 => 8208349094629138494, - 445 => 2108436006859028411, - 446 => -6092720355006722234, - 447 => 1968981523666278118, - 448 => -101963916550265467, - 449 => -3948811310562517646, - 450 => 3636703248408361268, - 451 => -1552158689729703948, - 452 => 344569421890938331, - 453 => 3153426948205039434, - 454 => 3831443709948604790, - 455 => -7482874978444912533, - 456 => -8980635650087970291, - 457 => -7420978390768120119, - 458 => -3805183150388771142, - 459 => -8592206455135356838, - 460 => -4169869898673179931, - 461 => 6663497159539159252, - 462 => 6865991479013201996, - 463 => -3658613259597233946, - 464 => -2486044299508991132, - 465 => 176634638428440638, - 466 => 3417847617901708310, - 467 => -3412736106075467201, - 468 => -47475402023430678, - 469 => -1844793694882286512, - 470 => -5222923010569976067, - 471 => -4436398227243152460, - 472 => 547747285585891162, - 473 => -6323683244389026449, - 474 => -4708566515748500503, - 475 => 5643562417717223350, - 476 => -5619618775527313253, - 477 => 8396858592130943772, - 478 => -81980553927762199, - 479 => 6409158638386858241, - 480 => 868451702856774451, - 481 => -7515541903071356571, - 482 => 2775746172925619768, - 483 => -3959430666688528952, - 484 => 6107868953750438655, - 485 => -2810795034820816925, - 486 => 4076844493593644827, - 487 => 8773464140668878334, - 488 => 665563913863651145, - 489 => 1758865298764529711, - 490 => 7470695950012076537, - 491 => -6427052574999633807, - 492 => -8853017404388704334, - 493 => -67654987091025103, - 494 => -5616973146317754880, - 495 => -6672515566919359409, - 496 => 415674102292236891, - 497 => -7370965881417330052, - 498 => 2496977896463373137, - 499 => 4815108696942023418, - 500 => 1448947258530766570, - 501 => -3659170523175704243, - 502 => -4051068912774759681, - 503 => -7076448156120582778, - 504 => -339502045327716956, - 505 => 7887873460024142462, - 506 => -5011349799595590590, - 507 => 4632660736855694530, - 508 => -8042521843475302648, - 509 => -93960121909642080, - 510 => -859279068895495769, - 511 => 1436502566364554793, - 512 => 4661650455009769138, - 513 => -1367319235255133031, - 514 => -2724699325313542291, - 515 => 4652447082911812293, - 516 => -5278219026866400834, - 517 => 6442301838607647893, - 518 => -9032634577889300878, - 519 => -2365413696709399012, - 520 => 291255837956078423, - 521 => -4324961647351857391, - 522 => 8366539432314551964, - 523 => -3618586235506258118, - 524 => -4088991976812578600, - 525 => 8866009886057376505, - 526 => -1164675704473499595, - 527 => -733828172710265947, - 528 => 3721170446183142566, - 529 => -7542197863491450437, - 530 => -1712621052183742250, - 531 => -3565518457683389659, - 532 => -3867814354031431969, - 533 => 1071054827462757220, - 534 => -5780308877220069255, - 535 => 6501231003855506209, - 536 => -8299609080785849722, - 537 => -2266799782662095574, - 538 => 1254437552556397638, - 539 => 7529094578579873888, - 540 => 9216111357151639783, - 541 => 4290842053926601137, - 542 => -408097871172205509, - 543 => -6098158652164334622, - 544 => 4560615506624619824, - 545 => 1441946062740964614, - 546 => -2356494385649000061, - 547 => -6393994505290781007, - 548 => 6268941505017737601, - 549 => -7026752638854795496, - 550 => -9007488950282488746, - 551 => 544823521126189784, - 552 => 5034374304218028947, - 553 => 4852392840271973608, - 554 => -7354838055116483992, - 555 => 4757982758220186480, - 556 => -3945886949840132900, - 557 => -7887258696170849338, - 558 => 6557666489885352857, - 559 => -4090135982574429680, - 560 => -2209417856246080539, - 561 => -7575371593857187593, - 562 => -8090177762677346748, - 563 => 2189297164944265391, - 564 => -5305673121306276106, - 565 => 8149527980046285739, - 566 => 9072803674881942311, - 567 => -3727781672496714946, - 568 => -4400190333335169546, - 569 => 4929789674243306992, - 570 => 6743618993461016585, - 571 => 5731315688971662726, - 572 => -3471064556019332724, - 573 => -7174609127936588654, - 574 => 3722867198854092467, - 575 => 1606440016596383813, - 576 => -2281489864617621195, - 577 => -1307142118175400213, - 578 => -8547196223739630571, - 579 => 3391767703832409341, - 580 => 8799898891798389498, - 581 => -1438033249762020363, - 582 => -5205883837927928287, - 583 => -354294276179153804, - 584 => 6548274220194567972, - 585 => -395094657710054060, - 586 => -223258724280665764, - 587 => -4141570294239017131, - 588 => -7018185330318606895, - 589 => -4745192051522803483, - 590 => -3035937451831963377, - 591 => -7320364774498020915, - 592 => 5203488311385588525, - 593 => 3921673848392800763, - 594 => 8352479268375121300, - 595 => -8628352876367206996, - 596 => 4723056794586165779, - 597 => -2817447054226988700, - 598 => 715197134215905262, - 599 => -7309324249306968779, - 600 => -7734152778173858377, - 601 => -5878373178705856204, - 602 => 5077302071396544677, - 603 => 4384550154340128969, - 604 => -2193553863697783876, - 605 => 6450438775605670536, - 606 => -6191431598372742659, - 607 => 6785579812047917231, - 608 => -7824530323089277441, - 609 => -8687366427736726977, - 610 => -9051816987087087647, - 611 => -2898779336555377483, - 612 => -8920792961980561914, - 613 => -1183810620103972743, - 614 => -9012986667578064937, - 615 => 5845271287684574247, - 616 => 89900067894800102, - 617 => 723451886389806228, - 618 => 4227548194166174723, - 619 => 35005151054137666, - 620 => 8157739297860697369, - 621 => -1333108648502887119, - 622 => 50337023990632811, - 623 => 8495968937583214559, - 624 => -3118644616312363936, - 625 => -339081784497171008, - 626 => -3883112634596268413, - 627 => 7371711793659079330, - 628 => 1131683747671733265, - 629 => 2829379398359422777, - 630 => -2233697304072295485, - 631 => 8343047786265395518, - 632 => -8943122549423061868, - 633 => -1499216027200102431, - 634 => -8227784499111018668, - 635 => 2069004878811864194, - 636 => -4801279027199694691, - 637 => 2591156145230303168, - 638 => -8229262055382287264, - 639 => -955232685823124917, - 640 => -7128627162717136214, - 641 => 3600549156336082400, - 642 => 4148832535826281234, - 643 => 6065767451699974502, - 644 => -5138657576901317318, - 645 => 3591402789813511717, - 646 => 9173864694539222259, - 647 => 7218260271166567449, - 648 => -8312738093967053513, - 649 => 7395441930341865752, - 650 => 4182669345947933511, - 651 => -5570822222802602811, - 652 => -8695090160166514763, - 653 => 3554391762483220057, - 654 => 7203892294365329317, - 655 => -1245686942434426689, - 656 => -9154373059619059776, - 657 => 8061423983278721267, - 658 => 274618224932948691, - 659 => 7238797143773480424, - 660 => 3042417581470073057, - 661 => -7470067382621240133, - 662 => -7155435792581656619, - 663 => -6750533560516847929, - 664 => -9100571687673475828, - 665 => 2172377672402610172, - 666 => 4607775954709915104, - 667 => 2633564710574450825, - 668 => -440466839734544329, - 669 => -1833683717353879571, - 670 => -3367050441671906983, - 671 => -7187391084983878601, - 672 => 6819949303744019304, - 673 => -7636595526428866807, - 674 => 1603598337796156446, - 675 => -2148110433211081121, - 676 => -4181764820584200478, - 677 => -226482004269571418, - 678 => -5092083714833001363, - 679 => -1586127894523091543, - 680 => -6940048956739022178, - 681 => 4325779775579872014, - 682 => -4493697402575059386, - 683 => -6942573353588993724, - 684 => -2369398773228867259, - 685 => 6523732807512685365, - 686 => -3914331226447729250, - 687 => -6312991331644753137, - 688 => 2463089075978487850, - 689 => 5942038886592587187, - 690 => -2736747757605557932, - 691 => -2604679761750363227, - 692 => -5236914441531458981, - 693 => -9129970263201345311, - 694 => -7841113372851620154, - 695 => 5110232547017368817, - 696 => 2963518158044809045, - 697 => -7594651228614914597, - 698 => 5965113606436673766, - 699 => 3754948836429818415, - 700 => -4719608804947903215, - 701 => 8640677616684078379, - 702 => 6967424873872529129, - 703 => -6089669733481258704, - 704 => 5599478864787022443, - 705 => 8314990936231051787, - 706 => 6311810127450425579, - 707 => 5249399024176335189, - 708 => 103842905214310526, - 709 => 8152692012953776669, - 710 => 5134884029603665767, - 711 => -5903272824635797618, - 712 => 2527592953365210976, - 713 => -6670772109936340503, - 714 => -8079363786114209212, - 715 => 202683570973492246, - 716 => -4780925294118263010, - 717 => 7791294875101563043, - 718 => -2434181289575299809, - 719 => 3096247300133031563, - 720 => -3382291029157281135, - 721 => -1633139325931102067, - 722 => 4055022258114515477, - 723 => 5184632271497691625, - 724 => 8041543039285260087, - 725 => 9169450631130174018, - 726 => -5994134443650836497, - 727 => 5377552931080754290, - 728 => 6781094978221293695, - 729 => -3058245258601876172, - 730 => 8647836490648561448, - 731 => 9204238357764121516, - 732 => 4639550637796145800, - 733 => -4036695914699606803, - 734 => -6586853967081591960, - 735 => 2217555294189448604, - 736 => 2462524099274386779, - 737 => 7038972471117135538, - 738 => -1258166079479930140, - 739 => 8154839192981506987, - 740 => 1378649999525075752, - 741 => 2265070541255812462, - 742 => 6660639262639355689, - 743 => 8278390549334049418, - 744 => 1398804134780334239, - 745 => 3951848085679927098, - 746 => -4860732352076459395, - 747 => 1752860345255544942, - 748 => 3518565518062206342, - 749 => 44635178712367668, - 750 => 8819357152559972510, - 751 => 4324473660628336159, - 752 => -8011743185024178590, - 753 => -8996407027677781508, - 754 => -711486139381222093, - 755 => -6215560460381736449, - 756 => 4859311728140826134, - 757 => -4154412386794590448, - 758 => -2187493165082612022, - 759 => 2464743043626754766, - 760 => -1278668725642229846, - 761 => 7535747723854303750, - 762 => -4599413124745507887, - 763 => -8384367724651183264, - 764 => -4768056484040511931, - 765 => 3903649810882634856, - 766 => -9114048027883989026, - 767 => -2320424958042444979, - 768 => -7915143986980574937, - 769 => -5990724003776925258, - 770 => 6400115942346890800, - 771 => -8457138652158711764, - 772 => -8401655182225845757, - 773 => 6750212895511422770, - 774 => 9090967212745014082, - 775 => -5414472999461007184, - 776 => 8429990020782938922, - 777 => 97664500888661427, - 778 => -1442483336869955176, - 779 => 6008593087619083741, - 780 => -1480697624698781186, - 781 => -4348967702172984534, - 782 => 3177361827679702377, - 783 => -6900631919905874181, - 784 => 6021444853957245659, - 785 => -7227850878153061194, - 786 => -1195874374241769354, - 787 => 6661093487619994495, - 788 => 4251053954778494552, - 789 => 4304300754415869912, - 790 => 8945951823030436209, - 791 => -2189536974954360033, - 792 => 4660601550115800006, - 793 => -8705718504226603426, - 794 => -30314380125555180, - 795 => -2124188600653105723, - 796 => -8988678114752811490, - 797 => -4661299667794090495, - 798 => -3716593098366518200, - 799 => -6963820656735835233, - 800 => 8306975118722797170, - 801 => -3180537092880844233, - 802 => 5818178421901066092, - 803 => 3466113066776082895, - 804 => 3236503107074434860, - 805 => 3692066395517072305, - 806 => -3321089923525302759, - 807 => 6149315052487044862, - 808 => -2314051100246146996, - 809 => 6965404851869135431, - 810 => -2796843551604500034, - 811 => -3337532210543781996, - 812 => -5075807979523229029, - 813 => -3013425084612083573, - 814 => 7060657560684690775, - 815 => 6094913806874935224, - 816 => -6632829607064036582, - 817 => -388777867445040277, - 818 => 194273700252962419, - 819 => -4637773599759175080, - 820 => 5658689583201756908, - 821 => 5927968034409883711, - 822 => -1926945266711223242, - 823 => 887124368422698254, - 824 => 7902874002962332365, - 825 => -5190573611684043966, - 826 => 6390068748505010312, - 827 => -8483588010833879249, - 828 => 7373119916255358592, - 829 => -8133440636763316932, - 830 => 7816690008378435750, - 831 => 6258129100564864529, - 832 => 84860055309189315, - 833 => 104217346528256607, - 834 => 1784411862595038508, - 835 => -6692758882762963920, - 836 => -392579159751869227, - 837 => -5440273793689547370, - 838 => 2211457723441433664, - 839 => 4677479183441445747, - 840 => -7237144321548105758, - 841 => 2067932511574341308, - 842 => -1840461952158254531, - 843 => -7275904528247510322, - 844 => -1017180139088664090, - 845 => -4593128485273960271, - 846 => -4362678013637898305, - 847 => 652729615873215153, - 848 => -8937166158943239239, - 849 => 7772201589069106918, - 850 => -4220901327248431319, - 851 => 5567144741691071653, - 852 => -4866863954385131954, - 853 => -3828628549119377123, - 854 => -8105422276414743310, - 855 => 6946066927781308917, - 856 => 2149454852811638966, - 857 => 3543049813335419073, - 858 => -5644203139571161234, - 859 => -230830575866440960, - 860 => -5166044678871911698, - 861 => -2426272925756130828, - 862 => -8733403867598818577, - 863 => -5393506827649123582, - 864 => -1905034835691728003, - 865 => 4931641918014241470, - 866 => 7399348859035757945, - 867 => 647810499281296411, - 868 => -1182376879388191632, - 869 => -5692663281107713947, - 870 => 115196835673478044, - 871 => -2826937891202652367, - 872 => 5683618595113999722, - 873 => -393518798616393564, - 874 => 2878586433222280062, - 875 => -3463835156768550086, - 876 => 3879474712065936314, - 877 => -4231953664287818315, - 878 => 5019011566836889768, - 879 => -4418878221582318478, - 880 => -3187384851282319501, - 881 => -6384937752772349038, - 882 => 2684172126043671085, - 883 => 124077701149568470, - 884 => -5041375737715627525, - 885 => -4637883959022440123, - 886 => -4637577816967663592, - 887 => -8371926557363522626, - 888 => 1269560195920399142, - 889 => -2774810987641595566, - 890 => -1613913261307275017, - 891 => 2651044762923498036, - 892 => -268379860966422832, - 893 => 7938127533340238065, - 894 => 9053830165287525824, - 895 => -7684035202762092701, - 896 => 6640066852353009558, - 897 => 3184916088507222283, - 898 => -7186118253069868344, - 899 => -8547548796601846206, - 900 => -6391111387808661828, - 901 => -6136185268635580285, - 902 => -300759434468849360, - 903 => 5294887371366644926, - 904 => -4582769374150405627, - 905 => 8090717093935427144, - 906 => -1670682816307185016, - 907 => 7056854629142196937, - 908 => -2910759880910102163, - 909 => 7361700069409734649, - 910 => -1690060789141443371, - 911 => -6683547544626397307, - 912 => -1019930487528113280, - 913 => 571575931060051486, - 914 => -4560281692828658072, - 915 => -7493981612348008717, - 916 => -878591107647456023, - 917 => 166198440251266051, - 918 => 665561950732786268, - 919 => 6200807398302711915, - 920 => -5580524710909594073, - 921 => 1669940693832753870, - 922 => 3170321178207205150, - 923 => 2998803801750296321, - 924 => 3126132563735407603, - 925 => 1763410990965719932, - 926 => 8011693403829410701, - 927 => -30338996460631921, - 928 => 3813039297977403180, - 929 => 7123611900334014372, - 930 => -6244239133370569777, - 931 => -2165861727345346781, - 932 => -9052223422370358053, - 933 => -7637648213028218507, - 934 => 8258740904849073848, - 935 => 2358340773665012611, - 936 => 2198343093499517862, - 937 => 757533622598785626, - 938 => -7110288085302027552, - 939 => -2603817203181154886, - 940 => -1344683278628798247, - 941 => 1328068394087933560, - 942 => -109678276064482657, - 943 => 5778692018223432558, - 944 => -5245768555498035311, - 945 => 5037331728004575260, - 946 => 7664194644963194966, - 947 => -2203796763742957964, - 948 => 2999841328490736427, - 949 => 8719499224375008549, - 950 => 7419402210670310694, - 951 => 1135029321797470055, - 952 => 2452413875197756640, - 953 => 3210502048366657435, - 954 => -3759195895003919766, - 955 => 7814835862455467029, - 956 => 257897893392878470, - 957 => -6396364988658192928, - 958 => -1306348054014052655, - 959 => 6066172523095173574, - 960 => 1521935404744234458, - 961 => 1784455976467862558, - 962 => 78433478117057585, - 963 => 5679820990451387189, - 964 => -3468334703938491107, - 965 => -2581454374397003300, - 966 => 1615438926725040316, - 967 => -5726442198683361780, - 968 => 85076344323286000, - 969 => -5112775195587054468, - 970 => -150307727175614379, - 971 => 5532355602662544800, - 972 => 7630967255623092283, - 973 => 6031601808396254731, - 974 => 2589259806720179012, - 975 => -2443438982692086376, - 976 => -5323633515992320591, - 977 => 5619225783179764001, - 978 => 6278136266045371772, - 979 => 1080635057999987543, - 980 => 2002009050098103958, - 981 => 6944494982368775038, - 982 => 8127064054714857053, - 983 => -9148606733100273122, - 984 => 3909782287020388198, - 985 => -1194357009610133253, - 986 => -8084026951783919511, - 987 => -1137276877760546631, - 988 => 2074327463971599953, - 989 => -9047662919993467959, - 990 => 9096773588823070330, - 991 => -5025192952012469599, - 992 => 1074614018506534433, - 993 => 6962038332185431193, - 994 => -5699727967137895044, - 995 => -3285423490225126731, - 996 => -901653703310797881, - 997 => -4554697698178367078, - 998 => 7855871831302852481, - 999 => 853126557890749925, + 0 => 3116543303436371270, + 1 => 4034046679743279349, + 2 => 6639786431571686935, + 3 => 3533715416917136650, + 4 => 2934750936249408219, + 5 => 4273092072666990683, + 6 => 5385701449530039789, + 7 => 6503913688409041149, + 8 => 402773279151700826, + 9 => 8448832716973993614, + 10 => 5249392152281175535, + 11 => 2119025889256270752, + 12 => 7545613320620969402, + 13 => 1267081254437679166, + 14 => 6638688682803267994, + 15 => 3811168923105593333, + 16 => 7801425660935424070, + 17 => 4638537397155756212, + 18 => 3336227127348517864, + 19 => 490430605298593916, + 20 => 7749859108393667655, + 21 => 7784903121954751211, + 22 => 2689180838823335132, + 23 => 3201188160230317405, + 24 => 7666999535802751045, + 25 => 3907852007225329373, + 26 => 681102653324990447, + 27 => 984198880517186809, + 28 => 7281021520576812734, + 29 => 4517531204418403731, + 30 => 1867846088391698427, + 31 => 119451944274392047, + 32 => 8449528393781012192, + 33 => 9059498292895738948, + 34 => 6744765370585138996, + 35 => 4729481646692733366, + 36 => 3639530511317810115, + 37 => 3416731466076088378, + 38 => 2274713086400043884, + 39 => 6736474757963912009, + 40 => 8960118989345160167, + 41 => 1117875966809036426, + 42 => 3929149294224752751, + 43 => 4931331394731128846, + 44 => 5279681728031549163, + 45 => 8822592093168461388, + 46 => 7414470063389851182, + 47 => 5239833362610514576, + 48 => 4596613772521782064, + 49 => 2054456919123729272, + 50 => 8051406216511742111, + 51 => 1831903703048752867, + 52 => 5711577814693799427, + 53 => 2072521705548947587, + 54 => 3303785016722223942, + 55 => 5780480490814878668, + 56 => 2806973307553567034, + 57 => 521371987637664732, + 58 => 4783183105405432666, + 59 => 4891269132128853835, + 60 => 1947054974807343942, + 61 => 1755868770575434564, + 62 => 3200064676974585436, + 63 => 3482743114913823401, + 64 => 8416129727579309167, + 65 => 743068710554950287, + 66 => 5931016063586989491, + 67 => 7158160677194506035, + 68 => 8799745419029368610, + 69 => 4451727819528475483, + 70 => 3512329845970825364, + 71 => 7164273558640904245, + 72 => 7605935996227196864, + 73 => 7641041918769873381, + 74 => 3711455010822415848, + 75 => 4385745197498509412, + 76 => 3399242595174603112, + 77 => 8209101086339668887, + 78 => 5996703855491661282, + 79 => 6834010528309990099, + 80 => 6324122336998460076, + 81 => 2865524922777966805, + 82 => 3331443589096288598, + 83 => 7529135289451496863, + 84 => 6653626302878807679, + 85 => 6704362651302811807, + 86 => 1079215225652757513, + 87 => 7379255287809212644, + 88 => 4826874304711191808, + 89 => 679901791634238016, + 90 => 6197020531018250014, + 91 => 8735259396103433562, + 92 => 7630517582615136573, + 93 => 9215315160548825122, + 94 => 7937271354627847789, + 95 => 5291151646915414506, + 96 => 9076151313634118254, + 97 => 207166856003870929, + 98 => 5258014016424655078, + 99 => 4309506613084898014, + 100 => 7122164888638983790, + 101 => 8051863862285343486, + 102 => 8201240372419791124, + 103 => 4044976239168551826, + 104 => 8930673061030935110, + 105 => 1018177283963397563, + 106 => 7408843252629200996, + 107 => 8913311978134800220, + 108 => 5220336409379918019, + 109 => 5586476568163888323, + 110 => 7882834315976998487, + 111 => 922236024812263604, + 112 => 2527660848372789070, + 113 => 8746728883939565815, + 114 => 5275082576929055613, + 115 => 6251912885413658326, + 116 => 7406462585383361334, + 117 => 3066600248726053890, + 118 => 9171602753189788305, + 119 => 9222105067242601263, + 120 => 8510925627631637852, + 121 => 2185288737321090128, + 122 => 594755165063324516, + 123 => 4156255950121482387, + 124 => 836325495194764104, + 125 => 8027357998795319979, + 126 => 3797157522879541740, + 127 => 1007095071712200984, + 128 => 7574891930615676470, + 129 => 5278487669134390108, + 130 => 7615916204826229876, + 131 => 7565834286983912460, + 132 => 6254551506244298990, + 133 => 5018689370950415617, + 134 => 5174215846969465625, + 135 => 5724585872180340565, + 136 => 8470460705200109675, + 137 => 7617783410106383627, + 138 => 448907544562377592, + 139 => 5507402440530233836, + 140 => 5398569845296843838, + 141 => 7675155126370645321, + 142 => 5971688577004125518, + 143 => 6768262462226232584, + 144 => 8774092471823326336, + 145 => 3090995081544055493, + 146 => 76531287009007653, + 147 => 7521959606745861360, + 148 => 6659116000942029308, + 149 => 4597178956565090490, + 150 => 480240787272938474, + 151 => 4187461063432336643, + 152 => 7740129368565433902, + 153 => 111301550774706185, + 154 => 5027067026010797756, + 155 => 2304366923609034077, + 156 => 8147303799388287413, + 157 => 1156134452803546028, + 158 => 7757005626338235537, + 159 => 7925749852136784352, + 160 => 4793662766231770312, + 161 => 1493921878504703024, + 162 => 5091484152653052512, + 163 => 3978258790491302442, + 164 => 6795828937656643895, + 165 => 8969193207402552570, + 166 => 7290296714010533816, + 167 => 4576450609460732872, + 168 => 4448651475831054075, + 169 => 3643527257251702441, + 170 => 7861940860374683483, + 171 => 6551632256609966710, + 172 => 3903542359964751612, + 173 => 3650323735873796999, + 174 => 1342237793372542742, + 175 => 8560830317526857166, + 176 => 7627101749535030780, + 177 => 6674581625777108441, + 178 => 7305407769238474803, + 179 => 8813573161610407062, + 180 => 7095308519960236063, + 181 => 2115093416054629919, + 182 => 9072828780515533019, + 183 => 4652525139445245764, + 184 => 7372667163152796371, + 185 => 2002216828090937302, + 186 => 2331113571621903576, + 187 => 4132586683729596555, + 188 => 5787237765522499383, + 189 => 9039244893597870387, + 190 => 2630267310843352900, + 191 => 3320934322416470069, + 192 => 1384361134246158412, + 193 => 6382401310004272732, + 194 => 3950081136665048590, + 195 => 7255624835579594929, + 196 => 9074773699985882314, + 197 => 8114124822886876753, + 198 => 4930846112119174754, + 199 => 594627245517462725, + 200 => 152600711147096924, + 201 => 5556086065458358184, + 202 => 1483789689642437892, + 203 => 7340905064139071767, + 204 => 3403969476570896320, + 205 => 3021089856447760530, + 206 => 6879793025598377308, + 207 => 6432239373635455216, + 208 => 2261449928175197867, + 209 => 3834948452072726877, + 210 => 5881262312100891351, + 211 => 8884990372979413887, + 212 => 1439998527712106799, + 213 => 7891082529154024555, + 214 => 6172369326666225534, + 215 => 5181373195000013522, + 216 => 607747328993458069, + 217 => 8237345339222963751, + 218 => 7547005188868429600, + 219 => 7848656531317882064, + 220 => 2578232704753235916, + 221 => 8804525518817252546, + 222 => 6000427276419986379, + 223 => 1201859145747058636, + 224 => 3645412970203662059, + 225 => 7324820426647201965, + 226 => 956580691106162195, + 227 => 6598227763444128727, + 228 => 400744770340460096, + 229 => 27908464175421153, + 230 => 6628823422534077264, + 231 => 5513874904389449337, + 232 => 1555999348623139070, + 233 => 5394094501031401411, + 234 => 1221629481655202809, + 235 => 8495545166429552202, + 236 => 3231377151249865691, + 237 => 5527889226292940205, + 238 => 1029590849753532992, + 239 => 5308304202546083277, + 240 => 275930502301824683, + 241 => 9209119143262156923, + 242 => 6167494410531906160, + 243 => 7830025580994109796, + 244 => 6507606822316898424, + 245 => 1929753045237646902, + 246 => 8919468780998748012, + 247 => 8420907641367221134, + 248 => 5763753526396249609, + 249 => 829911700097487449, + 250 => 1630054645586055293, + 251 => 3551830294268614912, + 252 => 1434270441711701349, + 253 => 5736574052567575980, + 254 => 7718001798796007650, + 255 => 2895803784885285024, + 256 => 6803380852329390125, + 257 => 5560273223532402776, + 258 => 6343089930701984734, + 259 => 4122925741907249369, + 260 => 8592567985315481222, + 261 => 3436494701466553952, + 262 => 3463451176331332951, + 263 => 187562144340041105, + 264 => 1543272816515954769, + 265 => 6029969585772382793, + 266 => 8601976912951295809, + 267 => 8382656593306897794, + 268 => 2568686015919949744, + 269 => 1377394042642365731, + 270 => 3162911290985780068, + 271 => 5000961222586323025, + 272 => 1237779275241480368, + 273 => 3258069522484618784, + 274 => 3032907893742877509, + 275 => 8054554585160859264, + 276 => 5940430260724712296, + 277 => 4531326722128165266, + 278 => 2065734207951110, + 279 => 7821165180369917805, + 280 => 1158698038717761773, + 281 => 6738149266443228550, + 282 => 3210157797283456945, + 283 => 6262170474949530150, + 284 => 7819145605249526013, + 285 => 308741852703655173, + 286 => 6109100692969606847, + 287 => 8666637826610919968, + 288 => 4414340812252007387, + 289 => 3143637470932688557, + 290 => 2558934211472951166, + 291 => 643775626307105874, + 292 => 8636622604686725821, + 293 => 2518418700601826998, + 294 => 7920244784069216201, + 295 => 1711926195059532274, + 296 => 4723076039979437402, + 297 => 4789556318672610021, + 298 => 3383762061084125713, + 299 => 81419587872397487, + 300 => 8959094208298803915, + 301 => 1050791417363451348, + 302 => 9064702789130783024, + 303 => 6399094909554574306, + 304 => 2782401565883356484, + 305 => 6596906848582970371, + 306 => 28135915513349597, + 307 => 4422221075655129295, + 308 => 8608221071414965817, + 309 => 6095278332958052662, + 310 => 2403859164402260260, + 311 => 6291401660881467138, + 312 => 3452969361602917872, + 313 => 2037667672432207140, + 314 => 1716765579604173657, + 315 => 8188451611558854426, + 316 => 3758018194165662223, + 317 => 7927173136315164692, + 318 => 5160321886102617637, + 319 => 5586860710380105894, + 320 => 3669094607447355182, + 321 => 4698807355983153680, + 322 => 8938374795480150331, + 323 => 999935909836499188, + 324 => 5731503837972423451, + 325 => 7687515164596408470, + 326 => 5187453404673016139, + 327 => 374347036973266174, + 328 => 7558055685076752663, + 329 => 8661074979403608186, + 330 => 1263380607134111284, + 331 => 8394761849903691171, + 332 => 185777652691059643, + 333 => 6039141846523184609, + 334 => 2863854187161003184, + 335 => 1691812858317803388, + 336 => 745254871729110181, + 337 => 6311866034235577571, + 338 => 1328701251343047176, + 339 => 1261536043440338037, + 340 => 6617296973665603822, + 341 => 1631773104319312970, + 342 => 4802273067505095481, + 343 => 3187421993071043500, + 344 => 2110040203117409350, + 345 => 9107955726818137623, + 346 => 3420190521538549809, + 347 => 8416577597564562449, + 348 => 1695286988471103701, + 349 => 215025034858386479, + 350 => 2481400223503499968, + 351 => 1092973757731808233, + 352 => 2135694617223149448, + 353 => 6553112383678716936, + 354 => 598601630749747653, + 355 => 3338565694521885762, + 356 => 2773355805865485473, + 357 => 5958574583704498452, + 358 => 6228535835649415551, + 359 => 576953217727500397, + 360 => 6194909289482050727, + 361 => 2099702174766059746, + 362 => 3278918512808957931, + 363 => 1278335701887880670, + 364 => 6951073332726182067, + 365 => 407440260203813339, + 366 => 6297197922788699998, + 367 => 3246124574815678026, + 368 => 7634457248712084650, + 369 => 2432077069272785469, + 370 => 4884656764390285387, + 371 => 4374755543865688982, + 372 => 4647095712195096938, + 373 => 201448442557251860, + 374 => 5477606527836982775, + 375 => 3177787147845989426, + 376 => 7870884948235994274, + 377 => 582907098014887703, + 378 => 1604364216747212668, + 379 => 714696257571952597, + 380 => 1190220868489114530, + 381 => 5894222502211048478, + 382 => 2054708445808027503, + 383 => 6650330645366120778, + 384 => 8584349113604498067, + 385 => 6840869868281742857, + 386 => 7092322752599487692, + 387 => 543135538174692036, + 388 => 2825300930950091034, + 389 => 7907179867402504351, + 390 => 3190544423401039762, + 391 => 2756670507005897405, + 392 => 1917582782295165689, + 393 => 6086093394294981749, + 394 => 9207877294980714647, + 395 => 5714605633796833179, + 396 => 2191885819092921163, + 397 => 772497103901488711, + 398 => 3314173782206281113, + 399 => 2337787878421796568, + 400 => 3438649131815828490, + 401 => 4094007803065881804, + 402 => 6324178564948827516, + 403 => 5836791135164109329, + 404 => 7392870551366890235, + 405 => 2821925757565085462, + 406 => 6123032262097226964, + 407 => 7953909746440381626, + 408 => 3062742355172253394, + 409 => 2208879325647414099, + 410 => 8958622939727816129, + 411 => 6048404681242944580, + 412 => 7156646522747526679, + 413 => 1329817134313758525, + 414 => 8994053034783763954, + 415 => 1800475039290277475, + 416 => 6872562616883978771, + 417 => 303672049665016371, + 418 => 7797654117808924349, + 419 => 8480840894831819863, + 420 => 902859111125050802, + 421 => 7680155113391437810, + 422 => 1527962868606603883, + 423 => 3959489870079719695, + 424 => 1449709050157488545, + 425 => 6307308060008211962, + 426 => 921934915520594294, + 427 => 6486727142794464625, + 428 => 5122782585040699356, + 429 => 8165757756077696098, + 430 => 9028759841501086247, + 431 => 4676592070795813938, + 432 => 2707745934740024636, + 433 => 4805941469873831297, + 434 => 5916314234915685009, + 435 => 7469642659391421254, + 436 => 5608602350673273896, + 437 => 5959458099592858381, + 438 => 1601143268910060213, + 439 => 647698806425510242, + 440 => 6701796324191153794, + 441 => 2807771076761196472, + 442 => 7572304907641493269, + 443 => 4229785926518447200, + 444 => 4104174547314569247, + 445 => 1054218003429514205, + 446 => 6177011859351414691, + 447 => 984490761833139059, + 448 => 9172390078579643074, + 449 => 7248966381573516985, + 450 => 1818351624204180634, + 451 => 8447292691989923834, + 452 => 172284710945469165, + 453 => 1576713474102519717, + 454 => 1915721854974302395, + 455 => 5481934547632319541, + 456 => 4733054211810790662, + 457 => 5512882841470715748, + 458 => 7320780461660390237, + 459 => 4927268809287097389, + 460 => 7138437087518185842, + 461 => 3331748579769579626, + 462 => 3432995739506600998, + 463 => 7394065407056158835, + 464 => 7980349887100280242, + 465 => 88317319214220319, + 466 => 1708923808950854155, + 467 => 7517003983817042207, + 468 => 9199634335843060469, + 469 => 8300975189413632552, + 470 => 6611910531569787774, + 471 => 7005172923233199578, + 472 => 273873642792945581, + 473 => 6061530414660262583, + 474 => 6869088778980525556, + 475 => 2821781208858611675, + 476 => 6413562649091119181, + 477 => 4198429296065471886, + 478 => 9182381759890894708, + 479 => 3204579319193429120, + 480 => 434225851428387225, + 481 => 5465601085319097522, + 482 => 1387873086462809884, + 483 => 7243656703510511332, + 484 => 3053934476875219327, + 485 => 7817974519444367345, + 486 => 2038422246796822413, + 487 => 4386732070334439167, + 488 => 332781956931825572, + 489 => 879432649382264855, + 490 => 3735347975006038268, + 491 => 6009845749354958904, + 492 => 4796863334660423641, + 493 => 9189544543309263256, + 494 => 6414885463695898368, + 495 => 5887114253395096103, + 496 => 207837051146118445, + 497 => 5537889096146110782, + 498 => 1248488948231686568, + 499 => 2407554348471011709, + 500 => 724473629265383285, + 501 => 7393786775266923686, + 502 => 7197837580467395967, + 503 => 5685147958794484419, + 504 => 9053621014190917330, + 505 => 3943936730012071231, + 506 => 6717697137056980513, + 507 => 2316330368427847265, + 508 => 5202111115117124484, + 509 => 9176391975899954768, + 510 => 8793732502407027923, + 511 => 718251283182277396, + 512 => 2330825227504884569, + 513 => 8539712419227209292, + 514 => 7861022374198004662, + 515 => 2326223541455906146, + 516 => 6584262523421575391, + 517 => 3221150919303823946, + 518 => 4707054747910125369, + 519 => 8040665188500076302, + 520 => 145627918978039211, + 521 => 7060891213178847112, + 522 => 4183269716157275982, + 523 => 7414078919101646749, + 524 => 7178876048448486508, + 525 => 4433004943028688252, + 526 => 8641034184618026010, + 527 => 8856457950499642834, + 528 => 1860585223091571283, + 529 => 5452273105109050589, + 530 => 8367061510762904683, + 531 => 7440612808013080978, + 532 => 7289464859839059823, + 533 => 535527413731378610, + 534 => 6333217598244741180, + 535 => 3250615501927753104, + 536 => 5073567496461850947, + 537 => 8089972145523728021, + 538 => 627218776278198819, + 539 => 3764547289289936944, + 540 => 4608055678575819891, + 541 => 2145421026963300568, + 542 => 9019323101268673053, + 543 => 6174292710772608497, + 544 => 2280307753312309912, + 545 => 720973031370482307, + 546 => 8045124844030275777, + 547 => 6026374784209385304, + 548 => 3134470752508868800, + 549 => 5709995717427378060, + 550 => 4719627561713531435, + 551 => 272411760563094892, + 552 => 2517187152109014473, + 553 => 2426196420135986804, + 554 => 5545953009296533812, + 555 => 2378991379110093240, + 556 => 7250428561934709358, + 557 => 5279742688769351139, + 558 => 3278833244942676428, + 559 => 7178304045567560968, + 560 => 8118663108731735538, + 561 => 5435686239926182011, + 562 => 5178283155516102434, + 563 => 1094648582472132695, + 564 => 6570535476201637755, + 565 => 4074763990023142869, + 566 => 4536401837440971155, + 567 => 7359481200606418335, + 568 => 7023276870187191035, + 569 => 2464894837121653496, + 570 => 3371809496730508292, + 571 => 2865657844485831363, + 572 => 7487839758845109446, + 573 => 5636067472886481481, + 574 => 1861433599427046233, + 575 => 803220008298191906, + 576 => 8082627104545965210, + 577 => 8569800977767075701, + 578 => 4949773924984960522, + 579 => 1695883851916204670, + 580 => 4399949445899194749, + 581 => 8504355411973765626, + 582 => 6620430117890811664, + 583 => 9046224898765198906, + 584 => 3274137110097283986, + 585 => 9025824707999748778, + 586 => 9111742674714442926, + 587 => 7152586889735267242, + 588 => 5714279371695472360, + 589 => 6850776011093374066, + 590 => 7705403310938794119, + 591 => 5563189649605765350, + 592 => 2601744155692794262, + 593 => 1960836924196400381, + 594 => 4176239634187560650, + 595 => 4909195598671172310, + 596 => 2361528397293082889, + 597 => 7814648509741281458, + 598 => 357598567107952631, + 599 => 5568709912201291418, + 600 => 5356295647767846619, + 601 => 6284185447501847706, + 602 => 2538651035698272338, + 603 => 2192275077170064484, + 604 => 8126595105005883870, + 605 => 3225219387802835268, + 606 => 6127656237668404478, + 607 => 3392789906023958615, + 608 => 5311106875310137087, + 609 => 4879688822986412319, + 610 => 4697463543311231984, + 611 => 7773982368577087066, + 612 => 4762975555864494851, + 613 => 8631466726802789436, + 614 => 4716878703065743339, + 615 => 2922635643842287123, + 616 => 44950033947400051, + 617 => 361725943194903114, + 618 => 2113774097083087361, + 619 => 17502575527068833, + 620 => 4078869648930348684, + 621 => 8556817712603332248, + 622 => 25168511995316405, + 623 => 4247984468791607279, + 624 => 7664049728698593840, + 625 => 9053831144606190304, + 626 => 7281815719556641601, + 627 => 3685855896829539665, + 628 => 565841873835866632, + 629 => 1414689699179711388, + 630 => 8106523384818628065, + 631 => 4171523893132697759, + 632 => 4751810762143244874, + 633 => 8473764023254724592, + 634 => 5109479787299266474, + 635 => 1034502439405932097, + 636 => 6822732523254928462, + 637 => 1295578072615151584, + 638 => 5108741009163632176, + 639 => 8745755693943213349, + 640 => 5659058455496207701, + 641 => 1800274578168041200, + 642 => 2074416267913140617, + 643 => 3032883725849987251, + 644 => 6654043248404117149, + 645 => 1795701394906755858, + 646 => 4586932347269611129, + 647 => 3609130135583283724, + 648 => 5067002989871249051, + 649 => 3697720965170932876, + 650 => 2091334672973966755, + 651 => 6437960925453474402, + 652 => 4875826956771518426, + 653 => 1777195881241610028, + 654 => 3601946147182664658, + 655 => 8600528565637562463, + 656 => 4646185507045245920, + 657 => 4030711991639360633, + 658 => 137309112466474345, + 659 => 3619398571886740212, + 660 => 1521208790735036528, + 661 => 5488338345544155741, + 662 => 5645654140563947498, + 663 => 5848105256596351843, + 664 => 4673086193018037894, + 665 => 1086188836201305086, + 666 => 2303887977354957552, + 667 => 1316782355287225412, + 668 => 9003138616987503643, + 669 => 8306530178177836022, + 670 => 7539846816018822316, + 671 => 5629676494362836507, + 672 => 3409974651872009652, + 673 => 5405074273640342404, + 674 => 801799168898078223, + 675 => 8149316820249235247, + 676 => 7132489626562675569, + 677 => 9110131034719990099, + 678 => 6677330179438275126, + 679 => 8430308089593230036, + 680 => 5753347558485264719, + 681 => 2162889887789936007, + 682 => 6976523335567246115, + 683 => 5752085360060278946, + 684 => 8038672650240342178, + 685 => 3261866403756342682, + 686 => 7266206423630911183, + 687 => 6066876371032399239, + 688 => 1231544537989243925, + 689 => 2971019443296293593, + 690 => 7854998158051996842, + 691 => 7921032155979594194, + 692 => 6604914816089046317, + 693 => 4658386905254103152, + 694 => 5302815350428965731, + 695 => 2555116273508684408, + 696 => 1481759079022404522, + 697 => 5426046422547318509, + 698 => 2982556803218336883, + 699 => 1877474418214909207, + 700 => 6863567634380824200, + 701 => 4320338808342039189, + 702 => 3483712436936264564, + 703 => 6178537170114146456, + 704 => 2799739432393511221, + 705 => 4157495468115525893, + 706 => 3155905063725212789, + 707 => 2624699512088167594, + 708 => 51921452607155263, + 709 => 4076346006476888334, + 710 => 2567442014801832883, + 711 => 6271735624536876999, + 712 => 1263796476682605488, + 713 => 5887985981886605556, + 714 => 5183690143797671202, + 715 => 101341785486746123, + 716 => 6832909389795644303, + 717 => 3895647437550781521, + 718 => 8006281392067125903, + 719 => 1548123650066515781, + 720 => 7532226522276135240, + 721 => 8406802373889224774, + 722 => 2027511129057257738, + 723 => 2592316135748845812, + 724 => 4020771519642630043, + 725 => 4584725315565087009, + 726 => 6226304815029357559, + 727 => 2688776465540377145, + 728 => 3390547489110646847, + 729 => 7694249407553837722, + 730 => 4323918245324280724, + 731 => 4602119178882060758, + 732 => 2319775318898072900, + 733 => 7205024079504972406, + 734 => 5929945053313979828, + 735 => 1108777647094724302, + 736 => 1231262049637193389, + 737 => 3519486235558567769, + 738 => 8594288997114810738, + 739 => 4077419596490753493, + 740 => 689324999762537876, + 741 => 1132535270627906231, + 742 => 3330319631319677844, + 743 => 4139195274667024709, + 744 => 699402067390167119, + 745 => 1975924042839963549, + 746 => 6793005860816546110, + 747 => 876430172627772471, + 748 => 1759282759031103171, + 749 => 22317589356183834, + 750 => 4409678576279986255, + 751 => 2162236830314168079, + 752 => 5217500444342686513, + 753 => 4725168523015885054, + 754 => 8867628967164164761, + 755 => 6115591806663907583, + 756 => 2429655864070413067, + 757 => 7146165843457480584, + 758 => 8129625454313469797, + 759 => 1232371521813377383, + 760 => 8584037674033660885, + 761 => 3767873861927151875, + 762 => 6923665474482021864, + 763 => 5031188174529184176, + 764 => 6839343794834519842, + 765 => 1951824905441317428, + 766 => 4666348022912781295, + 767 => 8063159557833553318, + 768 => 5265800043364488339, + 769 => 6228010034966313179, + 770 => 3200057971173445400, + 771 => 4994802710775419926, + 772 => 5022544445741852929, + 773 => 3375106447755711385, + 774 => 4545483606372507041, + 775 => 6516135537124272216, + 776 => 4214995010391469461, + 777 => 48832250444330713, + 778 => 8502130368419798220, + 779 => 3004296543809541870, + 780 => 8483023224505385215, + 781 => 7048888185768283541, + 782 => 1588680913839851188, + 783 => 5773056076901838717, + 784 => 3010722426978622829, + 785 => 5609446597778245211, + 786 => 8625434849733891131, + 787 => 3330546743809997247, + 788 => 2125526977389247276, + 789 => 2152150377207934956, + 790 => 4472975911515218104, + 791 => 8128603549377595791, + 792 => 2330300775057900003, + 793 => 4870512784741474095, + 794 => 9208214846791998218, + 795 => 8161277736528222946, + 796 => 4729032979478370063, + 797 => 6892722202957730560, + 798 => 7365075487671516708, + 799 => 5741461708486858191, + 800 => 4153487559361398585, + 801 => 7633103490414353691, + 802 => 2909089210950533046, + 803 => 1733056533388041447, + 804 => 1618251553537217430, + 805 => 1846033197758536152, + 806 => 7562827075092124428, + 807 => 3074657526243522431, + 808 => 8066346486731702310, + 809 => 3482702425934567715, + 810 => 7824950261052525791, + 811 => 7554605931582884810, + 812 => 6685468047093161293, + 813 => 7716659494548734021, + 814 => 3530328780342345387, + 815 => 3047456903437467612, + 816 => 5906957233322757517, + 817 => 9028983103132255669, + 818 => 97136850126481209, + 819 => 6904485236975188268, + 820 => 2829344791600878454, + 821 => 2963984017204941855, + 822 => 8259899403499164187, + 823 => 443562184211349127, + 824 => 3951437001481166182, + 825 => 6628085231012753825, + 826 => 3195034374252505156, + 827 => 4981578031437836183, + 828 => 3686559958127679296, + 829 => 5156651718473117342, + 830 => 3908345004189217875, + 831 => 3129064550282432264, + 832 => 42430027654594657, + 833 => 52108673264128303, + 834 => 892205931297519254, + 835 => 5876992595473293848, + 836 => 9027082456978841194, + 837 => 6503235140010002123, + 838 => 1105728861720716832, + 839 => 2338739591720722873, + 840 => 5604799876080722929, + 841 => 1033966255787170654, + 842 => 8303141060775648542, + 843 => 5585419772731020647, + 844 => 8714781967310443763, + 845 => 6926807794217795672, + 846 => 7042033030035826655, + 847 => 326364807936607576, + 848 => 4754788957383156188, + 849 => 3886100794534553459, + 850 => 7112921373230560148, + 851 => 2783572370845535826, + 852 => 6789940059662209831, + 853 => 7309057762295087246, + 854 => 5170660898647404153, + 855 => 3473033463890654458, + 856 => 1074727426405819483, + 857 => 1771524906667709536, + 858 => 6401270467069195191, + 859 => 9107956748921555328, + 860 => 6640349697418819959, + 861 => 8010235573976710394, + 862 => 4856670103055366519, + 863 => 6526618623030214017, + 864 => 8270854619008911806, + 865 => 2465820959007120735, + 866 => 3699674429517878972, + 867 => 323905249640648205, + 868 => 8632183597160679992, + 869 => 6377040396300918834, + 870 => 57598417836739022, + 871 => 7809903091253449624, + 872 => 2841809297556999861, + 873 => 9026612637546579026, + 874 => 1439293216611140031, + 875 => 7491454458470500765, + 876 => 1939737356032968157, + 877 => 7107395204710866650, + 878 => 2509505783418444884, + 879 => 7013932926063616569, + 880 => 7629679611213616057, + 881 => 6030903160468601289, + 882 => 1342086063021835542, + 883 => 62038850574784235, + 884 => 6702684167996962045, + 885 => 6904430057343555746, + 886 => 6904583128370944012, + 887 => 5037408758173014495, + 888 => 634780097960199571, + 889 => 7835966543033978025, + 890 => 8416415406201138299, + 891 => 1325522381461749018, + 892 => 9089182106371564392, + 893 => 3969063766670119032, + 894 => 4526915082643762912, + 895 => 5381354435473729457, + 896 => 3320033426176504779, + 897 => 1592458044253611141, + 898 => 5630312910319841636, + 899 => 4949597638553852705, + 900 => 6027816342950444894, + 901 => 6155279402536985665, + 902 => 9072992319620351128, + 903 => 2647443685683322463, + 904 => 6931987349779572994, + 905 => 4045358546967713572, + 906 => 8388030628701183300, + 907 => 3528427314571098468, + 908 => 7767992096399724726, + 909 => 3680850034704867324, + 910 => 8378341642284054122, + 911 => 5881598264541577154, + 912 => 8713406793090719168, + 913 => 285787965530025743, + 914 => 6943231190440446772, + 915 => 5476381230680771449, + 916 => 8784076483031047796, + 917 => 83099220125633025, + 918 => 332780975366393134, + 919 => 3100403699151355957, + 920 => 6433109681399978771, + 921 => 834970346916376935, + 922 => 1585160589103602575, + 923 => 1499401900875148160, + 924 => 1563066281867703801, + 925 => 881705495482859966, + 926 => 4005846701914705350, + 927 => 9208202538624459847, + 928 => 1906519648988701590, + 929 => 3561805950167007186, + 930 => 6101252470169490919, + 931 => 8140441173182102417, + 932 => 4697260325669596781, + 933 => 5404547930340666554, + 934 => 4129370452424536924, + 935 => 1179170386832506305, + 936 => 1099171546749758931, + 937 => 378766811299392813, + 938 => 5668227994203762032, + 939 => 7921463435264198365, + 940 => 8551030397540376684, + 941 => 664034197043966780, + 942 => 9168532898822534479, + 943 => 2889346009111716279, + 944 => 6600487759105758152, + 945 => 2518665864002287630, + 946 => 3832097322481597483, + 947 => 8121473654983296826, + 948 => 1499920664245368213, + 949 => 4359749612187504274, + 950 => 3709701105335155347, + 951 => 567514660898735027, + 952 => 1226206937598878320, + 953 => 1605251024183328717, + 954 => 7343774089352815925, + 955 => 3907417931227733514, + 956 => 128948946696439235, + 957 => 6025189542525679344, + 958 => 8570198009847749480, + 959 => 3033086261547586787, + 960 => 760967702372117229, + 961 => 892227988233931279, + 962 => 39216739058528792, + 963 => 2839910495225693594, + 964 => 7489204684885530254, + 965 => 7932644849656274158, + 966 => 807719463362520158, + 967 => 6360150937513094918, + 968 => 42538172161643000, + 969 => 6666984439061248574, + 970 => 9148218173266968618, + 971 => 2766177801331272400, + 972 => 3815483627811546141, + 973 => 3015800904198127365, + 974 => 1294629903360089506, + 975 => 8001652545508732620, + 976 => 6561555278858615512, + 977 => 2809612891589882000, + 978 => 3139068133022685886, + 979 => 540317528999993771, + 980 => 1001004525049051979, + 981 => 3472247491184387519, + 982 => 4063532027357428526, + 983 => 4649068670304639247, + 984 => 1954891143510194099, + 985 => 8626193532049709181, + 986 => 5181358560962816052, + 987 => 8654733597974502492, + 988 => 1037163731985799976, + 989 => 4699540576858041828, + 990 => 4548386794411535165, + 991 => 6710775560848541008, + 992 => 537307009253267216, + 993 => 3481019166092715596, + 994 => 6373508053285828286, + 995 => 7580660291742212442, + 996 => 8772545185199376867, + 997 => 6946023187765592269, + 998 => 3927935915651426240, + 999 => 426563278945374962, ); $rng = new \RNG\XorShift128Plus(SEED); foreach ($result as $ret) { - $rng_next = $rng->next64(); + $rng_next = \rng_next64($rng); if ($ret !== $rng_next) { die("NG, Result is inconsistent. RNG: ${rng_next} Result: ${ret}"); } diff --git a/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt b/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt index 2cd9d45c8f736..9519621d443c5 100644 --- a/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt +++ b/ext/standard/tests/rng/xorshift128plus_unserialize_unexcepted.phpt @@ -3,7 +3,7 @@ Test class: XorShift128Plus: unexcepted __unserialize(). --FILE-- --EXPECTF--