create-prisma-php-app 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (610) hide show
  1. package/LICENSE.txt +9 -0
  2. package/README.md +158 -0
  3. package/composer.json +23 -0
  4. package/composer.lock +812 -0
  5. package/dist/bootstrap.php +4 -0
  6. package/dist/index.js +2 -0
  7. package/dist/node_modules/prisma-client-php/index.enc +1 -0
  8. package/dist/node_modules/prisma-client-php/index.js +2 -0
  9. package/dist/node_modules/prisma-client-php/key.enc +1 -0
  10. package/dist/node_modules/prisma-client-php/package.json +7 -0
  11. package/dist/prisma/schema.prisma +32 -0
  12. package/dist/prisma/seed.js +68 -0
  13. package/dist/public/assets/images/prisma-php.png +0 -0
  14. package/dist/public/css/styles.css +0 -0
  15. package/dist/public/css/tailwind.css +3 -0
  16. package/dist/public/favicon.ico +0 -0
  17. package/dist/public/index.php +64 -0
  18. package/dist/settings/paths.php +10 -0
  19. package/dist/settings/project-settings.js +6 -0
  20. package/dist/src/app/api/api.php +39 -0
  21. package/dist/src/app/classes/Validator.php +77 -0
  22. package/dist/src/app/model/IModel.php +22 -0
  23. package/package.json +35 -0
  24. package/tsconfig.json +110 -0
  25. package/vendor/autoload.php +25 -0
  26. package/vendor/brick/math/.editorconfig +15 -0
  27. package/vendor/brick/math/.gitattributes +11 -0
  28. package/vendor/brick/math/.github/FUNDING.yml +1 -0
  29. package/vendor/brick/math/.github/workflows/ci.yml +80 -0
  30. package/vendor/brick/math/CHANGELOG.md +445 -0
  31. package/vendor/brick/math/LICENSE +20 -0
  32. package/vendor/brick/math/README.md +247 -0
  33. package/vendor/brick/math/composer.json +34 -0
  34. package/vendor/brick/math/phpunit.php +51 -0
  35. package/vendor/brick/math/phpunit.xml +13 -0
  36. package/vendor/brick/math/psalm.xml +28 -0
  37. package/vendor/brick/math/random-tests.php +162 -0
  38. package/vendor/brick/math/src/BigDecimal.php +786 -0
  39. package/vendor/brick/math/src/BigInteger.php +1079 -0
  40. package/vendor/brick/math/src/BigNumber.php +512 -0
  41. package/vendor/brick/math/src/BigRational.php +445 -0
  42. package/vendor/brick/math/src/Exception/DivisionByZeroException.php +35 -0
  43. package/vendor/brick/math/src/Exception/IntegerOverflowException.php +23 -0
  44. package/vendor/brick/math/src/Exception/MathException.php +12 -0
  45. package/vendor/brick/math/src/Exception/NegativeNumberException.php +12 -0
  46. package/vendor/brick/math/src/Exception/NumberFormatException.php +33 -0
  47. package/vendor/brick/math/src/Exception/RoundingNecessaryException.php +19 -0
  48. package/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php +75 -0
  49. package/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php +108 -0
  50. package/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php +581 -0
  51. package/vendor/brick/math/src/Internal/Calculator.php +676 -0
  52. package/vendor/brick/math/src/RoundingMode.php +107 -0
  53. package/vendor/brick/math/tests/AbstractTestCase.php +86 -0
  54. package/vendor/brick/math/tests/BigDecimalTest.php +2596 -0
  55. package/vendor/brick/math/tests/BigIntegerTest.php +3782 -0
  56. package/vendor/brick/math/tests/BigNumberTest.php +53 -0
  57. package/vendor/brick/math/tests/BigRationalTest.php +993 -0
  58. package/vendor/brick/math/tests/CalculatorDetectTest.php +25 -0
  59. package/vendor/brick/math/tests/Internal/Calculator/NativeCalculatorTest.php +87 -0
  60. package/vendor/composer/ClassLoader.php +579 -0
  61. package/vendor/composer/InstalledVersions.php +359 -0
  62. package/vendor/composer/LICENSE +21 -0
  63. package/vendor/composer/autoload_classmap.php +15 -0
  64. package/vendor/composer/autoload_files.php +13 -0
  65. package/vendor/composer/autoload_namespaces.php +9 -0
  66. package/vendor/composer/autoload_psr4.php +20 -0
  67. package/vendor/composer/autoload_real.php +50 -0
  68. package/vendor/composer/autoload_static.php +122 -0
  69. package/vendor/composer/installed.json +825 -0
  70. package/vendor/composer/installed.php +132 -0
  71. package/vendor/composer/platform_check.php +26 -0
  72. package/vendor/firebase/php-jwt/.gitattributes +9 -0
  73. package/vendor/firebase/php-jwt/.github/release-please.yml +3 -0
  74. package/vendor/firebase/php-jwt/.github/workflows/tests.yml +57 -0
  75. package/vendor/firebase/php-jwt/.php-cs-fixer.dist.php +24 -0
  76. package/vendor/firebase/php-jwt/CHANGELOG.md +170 -0
  77. package/vendor/firebase/php-jwt/LICENSE +30 -0
  78. package/vendor/firebase/php-jwt/README.md +424 -0
  79. package/vendor/firebase/php-jwt/composer.json +42 -0
  80. package/vendor/firebase/php-jwt/phpstan.neon.dist +5 -0
  81. package/vendor/firebase/php-jwt/phpunit.xml.dist +18 -0
  82. package/vendor/firebase/php-jwt/src/BeforeValidException.php +18 -0
  83. package/vendor/firebase/php-jwt/src/CachedKeySet.php +268 -0
  84. package/vendor/firebase/php-jwt/src/ExpiredException.php +18 -0
  85. package/vendor/firebase/php-jwt/src/JWK.php +349 -0
  86. package/vendor/firebase/php-jwt/src/JWT.php +669 -0
  87. package/vendor/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php +20 -0
  88. package/vendor/firebase/php-jwt/src/Key.php +64 -0
  89. package/vendor/firebase/php-jwt/src/SignatureInvalidException.php +7 -0
  90. package/vendor/firebase/php-jwt/tests/CachedKeySetTest.php +598 -0
  91. package/vendor/firebase/php-jwt/tests/JWKTest.php +172 -0
  92. package/vendor/firebase/php-jwt/tests/JWTTest.php +543 -0
  93. package/vendor/firebase/php-jwt/tests/data/ec-jwkset.json +40 -0
  94. package/vendor/firebase/php-jwt/tests/data/ecdsa-private.pem +18 -0
  95. package/vendor/firebase/php-jwt/tests/data/ecdsa-public.pem +9 -0
  96. package/vendor/firebase/php-jwt/tests/data/ecdsa256-private.pem +4 -0
  97. package/vendor/firebase/php-jwt/tests/data/ecdsa384-private.pem +6 -0
  98. package/vendor/firebase/php-jwt/tests/data/ecdsa384-public.pem +5 -0
  99. package/vendor/firebase/php-jwt/tests/data/ed25519-1.pub +1 -0
  100. package/vendor/firebase/php-jwt/tests/data/ed25519-1.sec +1 -0
  101. package/vendor/firebase/php-jwt/tests/data/ed25519-jwkset.json +11 -0
  102. package/vendor/firebase/php-jwt/tests/data/rsa-jwkset.json +18 -0
  103. package/vendor/firebase/php-jwt/tests/data/rsa-with-passphrase.pem +42 -0
  104. package/vendor/firebase/php-jwt/tests/data/rsa1-private.pem +27 -0
  105. package/vendor/firebase/php-jwt/tests/data/rsa1-public.pub +9 -0
  106. package/vendor/firebase/php-jwt/tests/data/rsa2-private.pem +27 -0
  107. package/vendor/firebase/php-jwt/tests/data/secp256k1-private.pem +5 -0
  108. package/vendor/firebase/php-jwt/tests/data/secp256k1-public.pem +4 -0
  109. package/vendor/graham-campbell/result-type/.gitattributes +9 -0
  110. package/vendor/graham-campbell/result-type/.github/CODE_OF_CONDUCT.md +132 -0
  111. package/vendor/graham-campbell/result-type/.github/CONTRIBUTING.md +31 -0
  112. package/vendor/graham-campbell/result-type/.github/FUNDING.yml +2 -0
  113. package/vendor/graham-campbell/result-type/.github/SECURITY.md +14 -0
  114. package/vendor/graham-campbell/result-type/.github/workflows/tests.yml +40 -0
  115. package/vendor/graham-campbell/result-type/CHANGELOG.md +43 -0
  116. package/vendor/graham-campbell/result-type/LICENSE +21 -0
  117. package/vendor/graham-campbell/result-type/README.md +42 -0
  118. package/vendor/graham-campbell/result-type/composer.json +33 -0
  119. package/vendor/graham-campbell/result-type/phpunit.xml.dist +13 -0
  120. package/vendor/graham-campbell/result-type/src/Error.php +121 -0
  121. package/vendor/graham-campbell/result-type/src/Result.php +69 -0
  122. package/vendor/graham-campbell/result-type/src/Success.php +120 -0
  123. package/vendor/graham-campbell/result-type/tests/ResultTest.php +95 -0
  124. package/vendor/hidehalo/nanoid-php/.editorconfig +15 -0
  125. package/vendor/hidehalo/nanoid-php/.gitattributes +8 -0
  126. package/vendor/hidehalo/nanoid-php/.github/workflows/php.yml +49 -0
  127. package/vendor/hidehalo/nanoid-php/.styleci.yml +1 -0
  128. package/vendor/hidehalo/nanoid-php/CHANGELOG.md +36 -0
  129. package/vendor/hidehalo/nanoid-php/CODE_OF_CONDUCT.md +74 -0
  130. package/vendor/hidehalo/nanoid-php/CONTRIBUTING.md +32 -0
  131. package/vendor/hidehalo/nanoid-php/ISSUE_TEMPLATE.md +27 -0
  132. package/vendor/hidehalo/nanoid-php/LICENSE.md +21 -0
  133. package/vendor/hidehalo/nanoid-php/PULL_REQUEST_TEMPLATE.md +43 -0
  134. package/vendor/hidehalo/nanoid-php/README.md +108 -0
  135. package/vendor/hidehalo/nanoid-php/benchmark/benchmark.php +24 -0
  136. package/vendor/hidehalo/nanoid-php/composer.json +62 -0
  137. package/vendor/hidehalo/nanoid-php/examples/basic_usage.php +24 -0
  138. package/vendor/hidehalo/nanoid-php/examples/custom_formated.php +29 -0
  139. package/vendor/hidehalo/nanoid-php/phpunit.xml +31 -0
  140. package/vendor/hidehalo/nanoid-php/src/Client.php +120 -0
  141. package/vendor/hidehalo/nanoid-php/src/Core.php +31 -0
  142. package/vendor/hidehalo/nanoid-php/src/CoreInterface.php +19 -0
  143. package/vendor/hidehalo/nanoid-php/src/Generator.php +13 -0
  144. package/vendor/hidehalo/nanoid-php/src/GeneratorInterface.php +13 -0
  145. package/vendor/hidehalo/nanoid-php/tests/ClientTest.php +76 -0
  146. package/vendor/hidehalo/nanoid-php/tests/CoreTest.php +37 -0
  147. package/vendor/hidehalo/nanoid-php/tests/GeneratorTest.php +34 -0
  148. package/vendor/hidehalo/nanoid-php/tests/Support/DummyGenerator.php +20 -0
  149. package/vendor/paragonie/random_compat/.gitattributes +14 -0
  150. package/vendor/paragonie/random_compat/.scrutinizer.yml +4 -0
  151. package/vendor/paragonie/random_compat/.travis.yml +59 -0
  152. package/vendor/paragonie/random_compat/CHANGELOG.md +3 -0
  153. package/vendor/paragonie/random_compat/LICENSE +22 -0
  154. package/vendor/paragonie/random_compat/RATIONALE.md +36 -0
  155. package/vendor/paragonie/random_compat/README.md +232 -0
  156. package/vendor/paragonie/random_compat/SECURITY.md +108 -0
  157. package/vendor/paragonie/random_compat/build-phar.sh +5 -0
  158. package/vendor/paragonie/random_compat/composer.json +34 -0
  159. package/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey +5 -0
  160. package/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc +11 -0
  161. package/vendor/paragonie/random_compat/lib/random.php +32 -0
  162. package/vendor/paragonie/random_compat/other/build_phar.php +57 -0
  163. package/vendor/paragonie/random_compat/other/ide_stubs/COM.php +20 -0
  164. package/vendor/paragonie/random_compat/other/ide_stubs/README.md +7 -0
  165. package/vendor/paragonie/random_compat/other/ide_stubs/com_exception.php +11 -0
  166. package/vendor/paragonie/random_compat/other/ide_stubs/libsodium.php +90 -0
  167. package/vendor/paragonie/random_compat/phpunit.sh +60 -0
  168. package/vendor/paragonie/random_compat/phpunit.xml.dist +31 -0
  169. package/vendor/paragonie/random_compat/psalm-autoload.php +9 -0
  170. package/vendor/paragonie/random_compat/psalm.xml +19 -0
  171. package/vendor/paragonie/random_compat/tests/full/DieHardTest.php +61 -0
  172. package/vendor/paragonie/random_compat/tests/full/StatTest.php +52 -0
  173. package/vendor/paragonie/random_compat/tests/specific/capicom.php +7 -0
  174. package/vendor/paragonie/random_compat/tests/specific/dev_urandom.php +7 -0
  175. package/vendor/paragonie/random_compat/tests/specific/libsodium.php +7 -0
  176. package/vendor/paragonie/random_compat/tests/specific/libsodium_legacy.php +7 -0
  177. package/vendor/paragonie/random_compat/tests/specific/mcrypt.php +7 -0
  178. package/vendor/paragonie/random_compat/tests/unit/RandomBytesTest.php +80 -0
  179. package/vendor/paragonie/random_compat/tests/unit/RandomIntTest.php +63 -0
  180. package/vendor/paragonie/random_compat/tests/unit/UtilityTest.php +95 -0
  181. package/vendor/paragonie/random_compat/tests/unit_with_basedir/RandomBytesTest.php +100 -0
  182. package/vendor/paragonie/random_compat/tests/unit_with_basedir/RandomIntTest.php +82 -0
  183. package/vendor/paragonie/random_compat/tests/unit_with_basedir/UtilityTest.php +95 -0
  184. package/vendor/phpoption/phpoption/.gitattributes +14 -0
  185. package/vendor/phpoption/phpoption/.github/CODE_OF_CONDUCT.md +132 -0
  186. package/vendor/phpoption/phpoption/.github/CONTRIBUTING.md +30 -0
  187. package/vendor/phpoption/phpoption/.github/FUNDING.yml +2 -0
  188. package/vendor/phpoption/phpoption/.github/SECURITY.md +14 -0
  189. package/vendor/phpoption/phpoption/.github/workflows/static.yml +74 -0
  190. package/vendor/phpoption/phpoption/.github/workflows/tests.yml +40 -0
  191. package/vendor/phpoption/phpoption/LICENSE +201 -0
  192. package/vendor/phpoption/phpoption/Makefile +26 -0
  193. package/vendor/phpoption/phpoption/README.md +194 -0
  194. package/vendor/phpoption/phpoption/composer.json +52 -0
  195. package/vendor/phpoption/phpoption/phpstan-baseline.neon +32 -0
  196. package/vendor/phpoption/phpoption/phpstan.neon.dist +8 -0
  197. package/vendor/phpoption/phpoption/phpunit.xml.dist +13 -0
  198. package/vendor/phpoption/phpoption/psalm.xml +12 -0
  199. package/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -0
  200. package/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -0
  201. package/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -0
  202. package/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -0
  203. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +77 -0
  204. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +200 -0
  205. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +153 -0
  206. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +160 -0
  207. package/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +194 -0
  208. package/vendor/phpoption/phpoption/tests/bootstrap.php +8 -0
  209. package/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +8 -0
  210. package/vendor/phpoption/phpoption/vendor-bin/psalm/composer.json +8 -0
  211. package/vendor/ramsey/uuid/.editorconfig +16 -0
  212. package/vendor/ramsey/uuid/.gitattributes +26 -0
  213. package/vendor/ramsey/uuid/.github/CODEOWNERS +1 -0
  214. package/vendor/ramsey/uuid/.github/FUNDING.yml +2 -0
  215. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Bug_Report.md +35 -0
  216. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Feature_Request.md +31 -0
  217. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Question.md +19 -0
  218. package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/config.yml +1 -0
  219. package/vendor/ramsey/uuid/.github/dependabot.yml +15 -0
  220. package/vendor/ramsey/uuid/.github/pull_request_template.md +27 -0
  221. package/vendor/ramsey/uuid/.github/workflows/continuous-integration.yml +181 -0
  222. package/vendor/ramsey/uuid/.github/workflows/merge-dependabot-upgrades.yml +24 -0
  223. package/vendor/ramsey/uuid/.readthedocs.yml +11 -0
  224. package/vendor/ramsey/uuid/CHANGELOG.md +1511 -0
  225. package/vendor/ramsey/uuid/CODE_OF_CONDUCT.md +73 -0
  226. package/vendor/ramsey/uuid/CONTRIBUTING.md +171 -0
  227. package/vendor/ramsey/uuid/LICENSE +19 -0
  228. package/vendor/ramsey/uuid/README.md +83 -0
  229. package/vendor/ramsey/uuid/SECURITY.md +170 -0
  230. package/vendor/ramsey/uuid/build/.gitignore +6 -0
  231. package/vendor/ramsey/uuid/build/cache/.gitkeep +0 -0
  232. package/vendor/ramsey/uuid/build/logs/.gitkeep +0 -0
  233. package/vendor/ramsey/uuid/captainhook.json +105 -0
  234. package/vendor/ramsey/uuid/codecov.yml +29 -0
  235. package/vendor/ramsey/uuid/composer.json +106 -0
  236. package/vendor/ramsey/uuid/composer.lock +7208 -0
  237. package/vendor/ramsey/uuid/docs/Makefile +20 -0
  238. package/vendor/ramsey/uuid/docs/README.md +36 -0
  239. package/vendor/ramsey/uuid/docs/_static/.gitkeep +0 -0
  240. package/vendor/ramsey/uuid/docs/conf.py +103 -0
  241. package/vendor/ramsey/uuid/docs/copyright.rst +18 -0
  242. package/vendor/ramsey/uuid/docs/customize/calculators.rst +75 -0
  243. package/vendor/ramsey/uuid/docs/customize/factory.rst +93 -0
  244. package/vendor/ramsey/uuid/docs/customize/ordered-time-codec.rst +86 -0
  245. package/vendor/ramsey/uuid/docs/customize/timestamp-first-comb-codec.rst +72 -0
  246. package/vendor/ramsey/uuid/docs/customize/validators.rst +39 -0
  247. package/vendor/ramsey/uuid/docs/customize.rst +56 -0
  248. package/vendor/ramsey/uuid/docs/database.rst +260 -0
  249. package/vendor/ramsey/uuid/docs/faq.rst +132 -0
  250. package/vendor/ramsey/uuid/docs/index.rst +51 -0
  251. package/vendor/ramsey/uuid/docs/introduction.rst +31 -0
  252. package/vendor/ramsey/uuid/docs/nonstandard/guid.rst +152 -0
  253. package/vendor/ramsey/uuid/docs/nonstandard/other.rst +49 -0
  254. package/vendor/ramsey/uuid/docs/nonstandard/version6.rst +17 -0
  255. package/vendor/ramsey/uuid/docs/nonstandard.rst +40 -0
  256. package/vendor/ramsey/uuid/docs/quickstart.rst +112 -0
  257. package/vendor/ramsey/uuid/docs/reference/calculators.rst +168 -0
  258. package/vendor/ramsey/uuid/docs/reference/exceptions.rst +92 -0
  259. package/vendor/ramsey/uuid/docs/reference/fields-fieldsinterface.rst +16 -0
  260. package/vendor/ramsey/uuid/docs/reference/guid-fields.rst +13 -0
  261. package/vendor/ramsey/uuid/docs/reference/guid-guid.rst +20 -0
  262. package/vendor/ramsey/uuid/docs/reference/helper.rst +62 -0
  263. package/vendor/ramsey/uuid/docs/reference/name-based-namespaces.rst +31 -0
  264. package/vendor/ramsey/uuid/docs/reference/nonstandard-fields.rst +13 -0
  265. package/vendor/ramsey/uuid/docs/reference/nonstandard-uuid.rst +20 -0
  266. package/vendor/ramsey/uuid/docs/reference/nonstandard-uuidv6.rst +34 -0
  267. package/vendor/ramsey/uuid/docs/reference/rfc4122-fieldsinterface.rst +78 -0
  268. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidinterface.rst +20 -0
  269. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv1.rst +21 -0
  270. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv2.rst +47 -0
  271. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv3.rst +13 -0
  272. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv4.rst +13 -0
  273. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv5.rst +13 -0
  274. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv6.rst +31 -0
  275. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv7.rst +20 -0
  276. package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv8.rst +13 -0
  277. package/vendor/ramsey/uuid/docs/reference/rfc4122-version.rst +87 -0
  278. package/vendor/ramsey/uuid/docs/reference/timebaseduuidinterface.rst +16 -0
  279. package/vendor/ramsey/uuid/docs/reference/types.rst +79 -0
  280. package/vendor/ramsey/uuid/docs/reference/uuid.rst +161 -0
  281. package/vendor/ramsey/uuid/docs/reference/uuidfactoryinterface.rst +102 -0
  282. package/vendor/ramsey/uuid/docs/reference/uuidinterface.rst +60 -0
  283. package/vendor/ramsey/uuid/docs/reference/validators.rst +34 -0
  284. package/vendor/ramsey/uuid/docs/reference/variant.rst +32 -0
  285. package/vendor/ramsey/uuid/docs/reference.rst +37 -0
  286. package/vendor/ramsey/uuid/docs/requirements.txt +3 -0
  287. package/vendor/ramsey/uuid/docs/rfc4122/version1.rst +192 -0
  288. package/vendor/ramsey/uuid/docs/rfc4122/version2.rst +273 -0
  289. package/vendor/ramsey/uuid/docs/rfc4122/version3.rst +68 -0
  290. package/vendor/ramsey/uuid/docs/rfc4122/version4.rst +39 -0
  291. package/vendor/ramsey/uuid/docs/rfc4122/version5.rst +108 -0
  292. package/vendor/ramsey/uuid/docs/rfc4122/version6.rst +213 -0
  293. package/vendor/ramsey/uuid/docs/rfc4122/version7.rst +173 -0
  294. package/vendor/ramsey/uuid/docs/rfc4122/version8.rst +51 -0
  295. package/vendor/ramsey/uuid/docs/rfc4122.rst +67 -0
  296. package/vendor/ramsey/uuid/docs/testing.rst +199 -0
  297. package/vendor/ramsey/uuid/docs/tidelift.rst +74 -0
  298. package/vendor/ramsey/uuid/docs/upgrading/2-to-3.rst +31 -0
  299. package/vendor/ramsey/uuid/docs/upgrading/3-to-4.rst +512 -0
  300. package/vendor/ramsey/uuid/docs/upgrading.rst +11 -0
  301. package/vendor/ramsey/uuid/phpbench.json +10 -0
  302. package/vendor/ramsey/uuid/phpcs.xml.dist +476 -0
  303. package/vendor/ramsey/uuid/phpstan-tests.neon +32 -0
  304. package/vendor/ramsey/uuid/phpstan.neon.dist +25 -0
  305. package/vendor/ramsey/uuid/phpunit.xml.dist +26 -0
  306. package/vendor/ramsey/uuid/psalm-baseline.xml +133 -0
  307. package/vendor/ramsey/uuid/psalm.xml +25 -0
  308. package/vendor/ramsey/uuid/resources/vagrant/README.md +10 -0
  309. package/vendor/ramsey/uuid/resources/vagrant/freebsd/README.md +15 -0
  310. package/vendor/ramsey/uuid/resources/vagrant/freebsd/Vagrantfile +35 -0
  311. package/vendor/ramsey/uuid/resources/vagrant/linux/README.md +15 -0
  312. package/vendor/ramsey/uuid/resources/vagrant/linux/Vagrantfile +27 -0
  313. package/vendor/ramsey/uuid/resources/vagrant/windows/README.md +16 -0
  314. package/vendor/ramsey/uuid/resources/vagrant/windows/Vagrantfile +22 -0
  315. package/vendor/ramsey/uuid/src/BinaryUtils.php +106 -0
  316. package/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php +68 -0
  317. package/vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php +39 -0
  318. package/vendor/ramsey/uuid/src/Codec/CodecInterface.php +67 -0
  319. package/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php +82 -0
  320. package/vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php +114 -0
  321. package/vendor/ramsey/uuid/src/Codec/StringCodec.php +128 -0
  322. package/vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php +105 -0
  323. package/vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php +51 -0
  324. package/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php +48 -0
  325. package/vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php +53 -0
  326. package/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php +118 -0
  327. package/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php +163 -0
  328. package/vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php +90 -0
  329. package/vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php +58 -0
  330. package/vendor/ramsey/uuid/src/Exception/BuilderNotFoundException.php +24 -0
  331. package/vendor/ramsey/uuid/src/Exception/DateTimeException.php +24 -0
  332. package/vendor/ramsey/uuid/src/Exception/DceSecurityException.php +25 -0
  333. package/vendor/ramsey/uuid/src/Exception/InvalidArgumentException.php +24 -0
  334. package/vendor/ramsey/uuid/src/Exception/InvalidBytesException.php +24 -0
  335. package/vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php +25 -0
  336. package/vendor/ramsey/uuid/src/Exception/NameException.php +25 -0
  337. package/vendor/ramsey/uuid/src/Exception/NodeException.php +24 -0
  338. package/vendor/ramsey/uuid/src/Exception/RandomSourceException.php +27 -0
  339. package/vendor/ramsey/uuid/src/Exception/TimeSourceException.php +24 -0
  340. package/vendor/ramsey/uuid/src/Exception/UnableToBuildUuidException.php +24 -0
  341. package/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php +24 -0
  342. package/vendor/ramsey/uuid/src/Exception/UuidExceptionInterface.php +21 -0
  343. package/vendor/ramsey/uuid/src/FeatureSet.php +395 -0
  344. package/vendor/ramsey/uuid/src/Fields/FieldsInterface.php +42 -0
  345. package/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php +70 -0
  346. package/vendor/ramsey/uuid/src/Generator/CombGenerator.php +124 -0
  347. package/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php +139 -0
  348. package/vendor/ramsey/uuid/src/Generator/DceSecurityGeneratorInterface.php +53 -0
  349. package/vendor/ramsey/uuid/src/Generator/DefaultNameGenerator.php +51 -0
  350. package/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php +131 -0
  351. package/vendor/ramsey/uuid/src/Generator/NameGeneratorFactory.php +30 -0
  352. package/vendor/ramsey/uuid/src/Generator/NameGeneratorInterface.php +38 -0
  353. package/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php +52 -0
  354. package/vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php +37 -0
  355. package/vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php +39 -0
  356. package/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php +45 -0
  357. package/vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php +30 -0
  358. package/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php +31 -0
  359. package/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php +45 -0
  360. package/vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php +38 -0
  361. package/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php +170 -0
  362. package/vendor/ramsey/uuid/src/Guid/Fields.php +208 -0
  363. package/vendor/ramsey/uuid/src/Guid/Guid.php +61 -0
  364. package/vendor/ramsey/uuid/src/Guid/GuidBuilder.php +79 -0
  365. package/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php +226 -0
  366. package/vendor/ramsey/uuid/src/Math/BrickMathCalculator.php +145 -0
  367. package/vendor/ramsey/uuid/src/Math/CalculatorInterface.php +106 -0
  368. package/vendor/ramsey/uuid/src/Math/RoundingMode.php +146 -0
  369. package/vendor/ramsey/uuid/src/Nonstandard/Fields.php +154 -0
  370. package/vendor/ramsey/uuid/src/Nonstandard/Uuid.php +37 -0
  371. package/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php +78 -0
  372. package/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php +113 -0
  373. package/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php +236 -0
  374. package/vendor/ramsey/uuid/src/Provider/DceSecurityProviderInterface.php +41 -0
  375. package/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php +54 -0
  376. package/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php +69 -0
  377. package/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php +74 -0
  378. package/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php +190 -0
  379. package/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php +30 -0
  380. package/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php +57 -0
  381. package/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php +33 -0
  382. package/vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php +28 -0
  383. package/vendor/ramsey/uuid/src/Rfc4122/Fields.php +214 -0
  384. package/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php +129 -0
  385. package/vendor/ramsey/uuid/src/Rfc4122/MaxTrait.php +41 -0
  386. package/vendor/ramsey/uuid/src/Rfc4122/MaxUuid.php +27 -0
  387. package/vendor/ramsey/uuid/src/Rfc4122/NilTrait.php +41 -0
  388. package/vendor/ramsey/uuid/src/Rfc4122/NilUuid.php +27 -0
  389. package/vendor/ramsey/uuid/src/Rfc4122/TimeTrait.php +55 -0
  390. package/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php +116 -0
  391. package/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php +30 -0
  392. package/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php +61 -0
  393. package/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php +119 -0
  394. package/vendor/ramsey/uuid/src/Rfc4122/UuidV3.php +58 -0
  395. package/vendor/ramsey/uuid/src/Rfc4122/UuidV4.php +58 -0
  396. package/vendor/ramsey/uuid/src/Rfc4122/UuidV5.php +58 -0
  397. package/vendor/ramsey/uuid/src/Rfc4122/UuidV6.php +30 -0
  398. package/vendor/ramsey/uuid/src/Rfc4122/UuidV7.php +63 -0
  399. package/vendor/ramsey/uuid/src/Rfc4122/UuidV8.php +65 -0
  400. package/vendor/ramsey/uuid/src/Rfc4122/Validator.php +45 -0
  401. package/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php +87 -0
  402. package/vendor/ramsey/uuid/src/Rfc4122/Version.php +139 -0
  403. package/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php +57 -0
  404. package/vendor/ramsey/uuid/src/TimeBasedUuidFactoryInterface.php +48 -0
  405. package/vendor/ramsey/uuid/src/TimeBasedUuidInterface.php +30 -0
  406. package/vendor/ramsey/uuid/src/Type/Decimal.php +135 -0
  407. package/vendor/ramsey/uuid/src/Type/Hexadecimal.php +109 -0
  408. package/vendor/ramsey/uuid/src/Type/Integer.php +145 -0
  409. package/vendor/ramsey/uuid/src/Type/NumberInterface.php +28 -0
  410. package/vendor/ramsey/uuid/src/Type/Time.php +108 -0
  411. package/vendor/ramsey/uuid/src/Type/TypeInterface.php +45 -0
  412. package/vendor/ramsey/uuid/src/Uuid.php +645 -0
  413. package/vendor/ramsey/uuid/src/UuidFactory.php +503 -0
  414. package/vendor/ramsey/uuid/src/UuidFactoryInterface.php +184 -0
  415. package/vendor/ramsey/uuid/src/UuidInterface.php +114 -0
  416. package/vendor/ramsey/uuid/src/Validator/GenericValidator.php +45 -0
  417. package/vendor/ramsey/uuid/src/Validator/ValidatorInterface.php +39 -0
  418. package/vendor/ramsey/uuid/src/Variant.php +60 -0
  419. package/vendor/ramsey/uuid/src/functions.php +160 -0
  420. package/vendor/ramsey/uuid/tests/BinaryUtilsTest.php +381 -0
  421. package/vendor/ramsey/uuid/tests/Builder/FallbackBuilderTest.php +198 -0
  422. package/vendor/ramsey/uuid/tests/Codec/GuidStringCodecTest.php +118 -0
  423. package/vendor/ramsey/uuid/tests/Codec/OrderedTimeCodecTest.php +258 -0
  424. package/vendor/ramsey/uuid/tests/Codec/StringCodecTest.php +149 -0
  425. package/vendor/ramsey/uuid/tests/Converter/Number/GenericNumberConverterTest.php +28 -0
  426. package/vendor/ramsey/uuid/tests/Converter/Time/GenericTimeConverterTest.php +147 -0
  427. package/vendor/ramsey/uuid/tests/Converter/Time/PhpTimeConverterTest.php +199 -0
  428. package/vendor/ramsey/uuid/tests/Converter/Time/UnixTimeConverterTest.php +202 -0
  429. package/vendor/ramsey/uuid/tests/Encoder/TimestampFirstCombCodecTest.php +105 -0
  430. package/vendor/ramsey/uuid/tests/Encoder/TimestampLastCombCodecTest.php +106 -0
  431. package/vendor/ramsey/uuid/tests/ExpectedBehaviorTest.php +573 -0
  432. package/vendor/ramsey/uuid/tests/FeatureSetTest.php +88 -0
  433. package/vendor/ramsey/uuid/tests/FunctionsTest.php +151 -0
  434. package/vendor/ramsey/uuid/tests/Generator/CombGeneratorTest.php +134 -0
  435. package/vendor/ramsey/uuid/tests/Generator/DceSecurityGeneratorTest.php +282 -0
  436. package/vendor/ramsey/uuid/tests/Generator/DefaultNameGeneratorTest.php +83 -0
  437. package/vendor/ramsey/uuid/tests/Generator/DefaultTimeGeneratorTest.php +202 -0
  438. package/vendor/ramsey/uuid/tests/Generator/NameGeneratorFactoryTest.php +19 -0
  439. package/vendor/ramsey/uuid/tests/Generator/PeclUuidNameGeneratorTest.php +107 -0
  440. package/vendor/ramsey/uuid/tests/Generator/PeclUuidRandomGeneratorTest.php +30 -0
  441. package/vendor/ramsey/uuid/tests/Generator/PeclUuidTimeGeneratorTest.php +30 -0
  442. package/vendor/ramsey/uuid/tests/Generator/RandomBytesGeneratorTest.php +70 -0
  443. package/vendor/ramsey/uuid/tests/Generator/RandomGeneratorFactoryTest.php +19 -0
  444. package/vendor/ramsey/uuid/tests/Generator/TimeGeneratorFactoryTest.php +33 -0
  445. package/vendor/ramsey/uuid/tests/Generator/UnixTimeGeneratorTest.php +204 -0
  446. package/vendor/ramsey/uuid/tests/Guid/FieldsTest.php +235 -0
  447. package/vendor/ramsey/uuid/tests/Guid/GuidBuilderTest.php +33 -0
  448. package/vendor/ramsey/uuid/tests/Math/BrickMathCalculatorTest.php +116 -0
  449. package/vendor/ramsey/uuid/tests/Nonstandard/FieldsTest.php +84 -0
  450. package/vendor/ramsey/uuid/tests/Nonstandard/UuidBuilderTest.php +33 -0
  451. package/vendor/ramsey/uuid/tests/Nonstandard/UuidV6Test.php +192 -0
  452. package/vendor/ramsey/uuid/tests/Provider/Dce/SystemDceSecurityProviderTest.php +505 -0
  453. package/vendor/ramsey/uuid/tests/Provider/Node/FallbackNodeProviderTest.php +87 -0
  454. package/vendor/ramsey/uuid/tests/Provider/Node/RandomNodeProviderTest.php +124 -0
  455. package/vendor/ramsey/uuid/tests/Provider/Node/StaticNodeProviderTest.php +58 -0
  456. package/vendor/ramsey/uuid/tests/Provider/Node/SystemNodeProviderTest.php +950 -0
  457. package/vendor/ramsey/uuid/tests/Provider/Time/FixedTimeProviderTest.php +41 -0
  458. package/vendor/ramsey/uuid/tests/Provider/Time/SystemTimeProviderTest.php +20 -0
  459. package/vendor/ramsey/uuid/tests/Rfc4122/FieldsTest.php +260 -0
  460. package/vendor/ramsey/uuid/tests/Rfc4122/UuidBuilderTest.php +145 -0
  461. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV1Test.php +123 -0
  462. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV2Test.php +214 -0
  463. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV3Test.php +56 -0
  464. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV4Test.php +56 -0
  465. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV5Test.php +56 -0
  466. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV6Test.php +221 -0
  467. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV7Test.php +131 -0
  468. package/vendor/ramsey/uuid/tests/Rfc4122/UuidV8Test.php +56 -0
  469. package/vendor/ramsey/uuid/tests/Rfc4122/ValidatorTest.php +122 -0
  470. package/vendor/ramsey/uuid/tests/Rfc4122/VariantTraitTest.php +109 -0
  471. package/vendor/ramsey/uuid/tests/TestCase.php +29 -0
  472. package/vendor/ramsey/uuid/tests/Type/DecimalTest.php +305 -0
  473. package/vendor/ramsey/uuid/tests/Type/HexadecimalTest.php +112 -0
  474. package/vendor/ramsey/uuid/tests/Type/IntegerTest.php +235 -0
  475. package/vendor/ramsey/uuid/tests/Type/TimeTest.php +120 -0
  476. package/vendor/ramsey/uuid/tests/UuidFactoryTest.php +233 -0
  477. package/vendor/ramsey/uuid/tests/UuidTest.php +1910 -0
  478. package/vendor/ramsey/uuid/tests/Validator/GenericValidatorTest.php +98 -0
  479. package/vendor/ramsey/uuid/tests/benchmark/GuidConversionBench.php +43 -0
  480. package/vendor/ramsey/uuid/tests/benchmark/NonLazyUuidConversionBench.php +39 -0
  481. package/vendor/ramsey/uuid/tests/benchmark/UuidFieldExtractionBench.php +86 -0
  482. package/vendor/ramsey/uuid/tests/benchmark/UuidGenerationBench.php +113 -0
  483. package/vendor/ramsey/uuid/tests/benchmark/UuidSerializationBench.php +206 -0
  484. package/vendor/ramsey/uuid/tests/benchmark/UuidStringConversionBench.php +257 -0
  485. package/vendor/ramsey/uuid/tests/bootstrap.php +12 -0
  486. package/vendor/ramsey/uuid/tests/static-analysis/UuidIsImmutable.php +96 -0
  487. package/vendor/ramsey/uuid/tests/static-analysis/UuidIsNeverEmpty.php +36 -0
  488. package/vendor/ramsey/uuid/tests/static-analysis/ValidUuidIsNonEmpty.php +44 -0
  489. package/vendor/ramsey/uuid/tests/static-analysis/stubs.php +33 -0
  490. package/vendor/symfony/polyfill-ctype/Ctype.php +232 -0
  491. package/vendor/symfony/polyfill-ctype/LICENSE +19 -0
  492. package/vendor/symfony/polyfill-ctype/README.md +12 -0
  493. package/vendor/symfony/polyfill-ctype/bootstrap.php +50 -0
  494. package/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -0
  495. package/vendor/symfony/polyfill-ctype/composer.json +41 -0
  496. package/vendor/symfony/polyfill-mbstring/LICENSE +19 -0
  497. package/vendor/symfony/polyfill-mbstring/Mbstring.php +947 -0
  498. package/vendor/symfony/polyfill-mbstring/README.md +13 -0
  499. package/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -0
  500. package/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -0
  501. package/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -0
  502. package/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -0
  503. package/vendor/symfony/polyfill-mbstring/bootstrap.php +151 -0
  504. package/vendor/symfony/polyfill-mbstring/bootstrap80.php +147 -0
  505. package/vendor/symfony/polyfill-mbstring/composer.json +41 -0
  506. package/vendor/symfony/polyfill-php80/LICENSE +19 -0
  507. package/vendor/symfony/polyfill-php80/Php80.php +115 -0
  508. package/vendor/symfony/polyfill-php80/PhpToken.php +103 -0
  509. package/vendor/symfony/polyfill-php80/README.md +25 -0
  510. package/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -0
  511. package/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -0
  512. package/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -0
  513. package/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -0
  514. package/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -0
  515. package/vendor/symfony/polyfill-php80/bootstrap.php +42 -0
  516. package/vendor/symfony/polyfill-php80/composer.json +40 -0
  517. package/vendor/vlucas/phpdotenv/.editorconfig +15 -0
  518. package/vendor/vlucas/phpdotenv/.gitattributes +17 -0
  519. package/vendor/vlucas/phpdotenv/.github/CODE_OF_CONDUCT.md +132 -0
  520. package/vendor/vlucas/phpdotenv/.github/CONTRIBUTING.md +30 -0
  521. package/vendor/vlucas/phpdotenv/.github/FUNDING.yml +2 -0
  522. package/vendor/vlucas/phpdotenv/.github/SECURITY.md +14 -0
  523. package/vendor/vlucas/phpdotenv/.github/workflows/static.yml +74 -0
  524. package/vendor/vlucas/phpdotenv/.github/workflows/tests.yml +70 -0
  525. package/vendor/vlucas/phpdotenv/LICENSE +30 -0
  526. package/vendor/vlucas/phpdotenv/Makefile +26 -0
  527. package/vendor/vlucas/phpdotenv/README.md +363 -0
  528. package/vendor/vlucas/phpdotenv/UPGRADING.md +196 -0
  529. package/vendor/vlucas/phpdotenv/composer.json +60 -0
  530. package/vendor/vlucas/phpdotenv/phpstan-baseline.neon +21 -0
  531. package/vendor/vlucas/phpdotenv/phpstan.neon.dist +7 -0
  532. package/vendor/vlucas/phpdotenv/phpunit.xml.dist +13 -0
  533. package/vendor/vlucas/phpdotenv/psalm-baseline.xml +28 -0
  534. package/vendor/vlucas/phpdotenv/psalm.xml +13 -0
  535. package/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -0
  536. package/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -0
  537. package/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -0
  538. package/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -0
  539. package/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -0
  540. package/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -0
  541. package/vendor/vlucas/phpdotenv/src/Loader/Loader.php +47 -0
  542. package/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -0
  543. package/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -0
  544. package/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -0
  545. package/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +300 -0
  546. package/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -0
  547. package/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -0
  548. package/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -0
  549. package/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -0
  550. package/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -0
  551. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -0
  552. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -0
  553. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -0
  554. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +89 -0
  555. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -0
  556. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -0
  557. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -0
  558. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -0
  559. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -0
  560. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -0
  561. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -0
  562. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +89 -0
  563. package/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -0
  564. package/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -0
  565. package/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -0
  566. package/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -0
  567. package/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -0
  568. package/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -0
  569. package/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -0
  570. package/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -0
  571. package/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -0
  572. package/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -0
  573. package/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -0
  574. package/vendor/vlucas/phpdotenv/src/Util/Str.php +98 -0
  575. package/vendor/vlucas/phpdotenv/src/Validator.php +209 -0
  576. package/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +387 -0
  577. package/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +86 -0
  578. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +234 -0
  579. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +40 -0
  580. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +53 -0
  581. package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +98 -0
  582. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +57 -0
  583. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +75 -0
  584. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +52 -0
  585. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +75 -0
  586. package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +305 -0
  587. package/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +141 -0
  588. package/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +479 -0
  589. package/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +5 -0
  590. package/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +18 -0
  591. package/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +33 -0
  592. package/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +15 -0
  593. package/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +1 -0
  594. package/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +1 -0
  595. package/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +7 -0
  596. package/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +1 -0
  597. package/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +17 -0
  598. package/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +2 -0
  599. package/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +3 -0
  600. package/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +14 -0
  601. package/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +4 -0
  602. package/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +1 -0
  603. package/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +15 -0
  604. package/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +11 -0
  605. package/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +8 -0
  606. package/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +2 -0
  607. package/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +3 -0
  608. package/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +1 -0
  609. package/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +16 -0
  610. package/vendor/vlucas/phpdotenv/vendor-bin/psalm/composer.json +9 -0
@@ -0,0 +1,3782 @@
1
+ <?php
2
+
3
+ declare(strict_types=1);
4
+
5
+ namespace Brick\Math\Tests;
6
+
7
+ use Brick\Math\BigInteger;
8
+ use Brick\Math\Exception\IntegerOverflowException;
9
+ use Brick\Math\Exception\MathException;
10
+ use Brick\Math\Exception\NegativeNumberException;
11
+ use Brick\Math\Exception\NumberFormatException;
12
+ use Brick\Math\Exception\DivisionByZeroException;
13
+ use Brick\Math\Exception\RoundingNecessaryException;
14
+ use Brick\Math\Internal\Calculator;
15
+ use Brick\Math\RoundingMode;
16
+
17
+ use Generator;
18
+
19
+ /**
20
+ * Unit tests for class BigInteger.
21
+ */
22
+ class BigIntegerTest extends AbstractTestCase
23
+ {
24
+ /**
25
+ * @dataProvider providerOf
26
+ *
27
+ * @param string|number $value The value to convert to a BigInteger.
28
+ * @param string $expected The expected string value of the result.
29
+ */
30
+ public function testOf($value, string $expected) : void
31
+ {
32
+ self::assertBigIntegerEquals($expected, BigInteger::of($value));
33
+ }
34
+
35
+ public function providerOf() : array
36
+ {
37
+ return [
38
+ [0, '0'],
39
+ [1, '1'],
40
+ [-1, '-1'],
41
+ [123456789, '123456789'],
42
+ [-123456789, '-123456789'],
43
+ [PHP_INT_MAX, (string) PHP_INT_MAX],
44
+ [PHP_INT_MIN, (string) PHP_INT_MIN],
45
+
46
+ [0.0, '0'],
47
+ [1.0, '1'],
48
+ [-0.0, '0'],
49
+ [-1.0, '-1'],
50
+
51
+ ['0.0', '0'],
52
+ ['1.0', '1'],
53
+ ['-1.00', '-1'],
54
+
55
+ ['.0', '0'],
56
+ ['.00', '0'],
57
+
58
+ [1.2e5, '120000'],
59
+ [-1.2e5, '-120000'],
60
+
61
+ ['1e20', '100000000000000000000'],
62
+ ['-3e+50', '-300000000000000000000000000000000000000000000000000'],
63
+
64
+ ['0', '0'],
65
+ ['+0', '0'],
66
+ ['-0', '0'],
67
+
68
+ ['1.', '1'],
69
+ ['+2.', '2'],
70
+ ['-3.', '-3'],
71
+
72
+ ['1.e0', '1'],
73
+ ['1.e2', '100'],
74
+ ['-1.e2', '-100'],
75
+ ['+1.e3', '1000'],
76
+ ['.1e1', '1'],
77
+ ['.1e2', '10'],
78
+ ['-.1e2', '-10'],
79
+ ['+.1e3', '100'],
80
+
81
+ ['1', '1'],
82
+ ['+1', '1'],
83
+ ['-1', '-1'],
84
+
85
+ ['00', '0'],
86
+ ['+00', '0'],
87
+ ['-00', '0'],
88
+
89
+ ['01', '1'],
90
+ ['+01', '1'],
91
+ ['-01', '-1'],
92
+
93
+ ['123456789012345678901234567890', '123456789012345678901234567890'],
94
+ ['+123456789012345678901234567890', '123456789012345678901234567890'],
95
+ ['-123456789012345678901234567890', '-123456789012345678901234567890'],
96
+
97
+ ['0123456789012345678901234567890', '123456789012345678901234567890'],
98
+ ['+0123456789012345678901234567890', '123456789012345678901234567890'],
99
+ ['-0123456789012345678901234567890', '-123456789012345678901234567890'],
100
+
101
+ ['00123456789012345678901234567890', '123456789012345678901234567890'],
102
+ ['+00123456789012345678901234567890', '123456789012345678901234567890'],
103
+ ['-00123456789012345678901234567890', '-123456789012345678901234567890'],
104
+ ];
105
+ }
106
+
107
+ public function testOfBigIntegerReturnsThis() : void
108
+ {
109
+ $decimal = BigInteger::of(123);
110
+
111
+ self::assertSame($decimal, BigInteger::of($decimal));
112
+ }
113
+
114
+ /**
115
+ * @dataProvider providerOfInvalidFormatThrowsException
116
+ *
117
+ * @param string|number $value
118
+ */
119
+ public function testOfInvalidFormatThrowsException($value) : void
120
+ {
121
+ $this->expectException(NumberFormatException::class);
122
+ BigInteger::of($value);
123
+ }
124
+
125
+ public function providerOfInvalidFormatThrowsException() : array
126
+ {
127
+ return [
128
+ [''],
129
+ ['a'],
130
+ [' 1'],
131
+ ['1 '],
132
+ ['+'],
133
+ ['-'],
134
+ ['+a'],
135
+ ['-a'],
136
+ ['a0'],
137
+ ['0a'],
138
+ ['1.a'],
139
+ ['a.1'],
140
+ ];
141
+ }
142
+
143
+ /**
144
+ * @dataProvider providerOfNonConvertibleValueThrowsException
145
+ *
146
+ * @param float|string $value
147
+ */
148
+ public function testOfNonConvertibleValueThrowsException($value) : void
149
+ {
150
+ $this->expectException(RoundingNecessaryException::class);
151
+ BigInteger::of($value);
152
+ }
153
+
154
+ public function providerOfNonConvertibleValueThrowsException() : array
155
+ {
156
+ return [
157
+ [1.1],
158
+ ['1e-1'],
159
+ ['7/9'],
160
+ ];
161
+ }
162
+
163
+ /**
164
+ * @dataProvider providerFromBase
165
+ *
166
+ * @param string $number The number to create.
167
+ * @param int $base The base of the number.
168
+ * @param string $expected The expected result in base 10.
169
+ */
170
+ public function testFromBase(string $number, int $base, string $expected) : void
171
+ {
172
+ self::assertBigIntegerEquals($expected, BigInteger::fromBase($number, $base));
173
+ }
174
+
175
+ /**
176
+ * @return array
177
+ */
178
+ public function providerFromBase() : array
179
+ {
180
+ return [
181
+ ['0', 10, '0'],
182
+ ['-0', 10, '0'],
183
+ ['+0', 10, '0'],
184
+ ['00', 16, '0'],
185
+ ['-00', 16, '0'],
186
+ ['+00', 16, '0'],
187
+
188
+ ['1', 10, '1'],
189
+ ['-1', 10, '-1'],
190
+ ['+1', 10, '1'],
191
+ ['01', 8, '1'],
192
+ ['-01', 8, '-1'],
193
+ ['+01', 8, '1'],
194
+
195
+ ['123', 10, '123'],
196
+ ['+456', 10, '456'],
197
+ ['-789', 10, '-789'],
198
+ ['0123', 10, '123'],
199
+ ['+0456', 10, '456'],
200
+ ['-0789', 10, '-789'],
201
+
202
+ ['123', 11, '146'],
203
+ ['+456', 11, '545'],
204
+ ['-789', 11, '-944'],
205
+ ['0123', 11, '146'],
206
+ ['+0456', 11, '545'],
207
+ ['-0789', 11, '-944'],
208
+
209
+ ['110011001100110011001111', 36, '640998479760579495168036691627608949'],
210
+ ['110011001100110011001111', 35, '335582856048758779730579523833856636'],
211
+ ['110011001100110011001111', 34, '172426711023004493064981145981549295'],
212
+ ['110011001100110011001111', 33, '86853227285668653965326574185738990'],
213
+ ['110011001100110011001111', 32, '42836489934972583913564073319498785'],
214
+ ['110011001100110011001111', 31, '20658924711984480538771889603666144'],
215
+ ['110011001100110011001111', 30, '9728140488839986222205212599027931'],
216
+ ['110011001100110011001111', 29, '4465579470019956787945275674107410'],
217
+ ['110011001100110011001111', 28, '1994689924537781753408144504465645'],
218
+ ['110011001100110011001111', 27, '865289950909412968716094193925700'],
219
+ ['110011001100110011001111', 26, '363729369583879309352831568000039'],
220
+ ['110011001100110011001111', 25, '147793267388865354156500488297526'],
221
+ ['110011001100110011001111', 24, '57888012016107577099138793486425'],
222
+ ['110011001100110011001111', 23, '21788392294523974761749372677800'],
223
+ ['110011001100110011001111', 22, '7852874701996329566765721637715'],
224
+ ['110011001100110011001111', 21, '2699289081943123258094476428634'],
225
+ ['110011001100110011001111', 20, '880809345058406615041344008421'],
226
+ ['110011001100110011001111', 19, '271401690926468032718781859340'],
227
+ ['110011001100110011001111', 18, '78478889737009209699633503455'],
228
+ ['110011001100110011001111', 17, '21142384915931646646976872830'],
229
+ ['110011001100110011001111', 16, '5261325448418072742917574929'],
230
+ ['110011001100110011001111', 15, '1197116069565850925807253616'],
231
+ ['110011001100110011001111', 14, '245991074299834917455374155'],
232
+ ['110011001100110011001111', 13, '44967318722190498361960610'],
233
+ ['110011001100110011001111', 12, '7177144825886069940574045'],
234
+ ['110011001100110011001111', 11, '976899716207148313491924'],
235
+ ['110011001100110011001111', 10, '110011001100110011001111'],
236
+ ['110011001100110011001111', 9, '9849210196991880028870'],
237
+ ['110011001100110011001111', 8, '664244955832213832265'],
238
+ ['110011001100110011001111', 7, '31291601125492514360'],
239
+ ['110011001100110011001111', 6, '922063395565287619'],
240
+ ['110011001100110011001111', 5, '14328039609468906'],
241
+ ['110011001100110011001111', 4, '88305875046485'],
242
+ ['110011001100110011001111', 3, '127093291420'],
243
+ ['110011001100110011001111', 2, '13421775'],
244
+
245
+ ['ZyXwVuTsRqPoNmLkJiHgFeDcBa9876543210', 36, '106300512100105327644605138221229898724869759421181854980'],
246
+ ['YxWvUtSrQpOnMlKjIhGfEdCbA9876543210', 35, '1101553773143634726491620528194292510495517905608180485'],
247
+ ['XwVuTsRqPoNmLkJiHgFeDcBa9876543210', 34, '11745843093701610854378775891116314824081102660800418'],
248
+ ['WvUtSrQpOnMlKjIhGfEdCbA9876543210', 33, '128983956064237823710866404905431464703849549412368'],
249
+ ['VuTsRqPoNmLkJiHgFeDcBa9876543210', 32, '1459980823972598128486511383358617792788444579872'],
250
+ ['UtSrQpOnMlKjIhGfEdCbA9876543210', 31, '17050208381689099029767742314582582184093573615'],
251
+ ['TsRqPoNmLkJiHgFeDcBa9876543210', 30, '205646315052919334126040428061831153388822830'],
252
+ ['SrQpOnMlKjIhGfEdCbA9876543210', 29, '2564411043271974895869785066497940850811934'],
253
+ ['RqPoNmLkJiHgFeDcBa9876543210', 28, '33100056003358651440264672384704297711484'],
254
+ ['QpOnMlKjIhGfEdCbA9876543210', 27, '442770531899482980347734468443677777577'],
255
+ ['PoNmLkJiHgFeDcBa9876543210', 26, '6146269788878825859099399609538763450'],
256
+ ['OnMlKjIhGfEdCbA9876543210', 25, '88663644327703473714387251271141900'],
257
+ ['NmLkJiHgFeDcBa9876543210', 24, '1331214537196502869015340298036888'],
258
+ ['MlKjIhGfEdCbA9876543210', 23, '20837326537038308910317109288851'],
259
+ ['LkJiHgFeDcBa9876543210', 22, '340653664490377789692799452102'],
260
+ ['KjIhGfEdCbA9876543210', 21, '5827980550840017565077671610'],
261
+ ['JiHgFeDcBa9876543210', 20, '104567135734072022160664820'],
262
+ ['IhGfEdCbA9876543210', 19, '1972313422155189164466189'],
263
+ ['HgFeDcBa9876543210', 18, '39210261334551566857170'],
264
+ ['GfEdCbA9876543210', 17, '824008854613343261192'],
265
+ ['FeDcBa9876543210', 16, '18364758544493064720'],
266
+ ['EdCbA9876543210', 15, '435659737878916215'],
267
+ ['DcBa9876543210', 14, '11046255305880158'],
268
+ ['CbA9876543210', 13, '300771807240918'],
269
+ ['Ba9876543210', 12, '8842413667692'],
270
+ ['A9876543210', 11, '282458553905'],
271
+ ['9876543210', 10, '9876543210'],
272
+ ['876543210', 9, '381367044'],
273
+ ['76543210', 8, '16434824'],
274
+ ['6543210', 7, '800667'],
275
+ ['543210', 6, '44790'],
276
+ ['43210', 5, '2930'],
277
+ ['3210', 4, '228'],
278
+ ['210', 3, '21'],
279
+ ['10', 2, '2'],
280
+ ];
281
+ }
282
+
283
+ /**
284
+ * @dataProvider providerFromBaseWithInvalidValue
285
+ */
286
+ public function testFromBaseWithInvalidValue(string $value, int $base) : void
287
+ {
288
+ $this->expectException(NumberFormatException::class);
289
+ BigInteger::fromBase($value, $base);
290
+ }
291
+
292
+ public function providerFromBaseWithInvalidValue() : array
293
+ {
294
+ return [
295
+ ['', 10],
296
+ [' ', 10],
297
+ ['+', 10],
298
+ ['-', 10],
299
+ ['1 ', 10],
300
+ [' 1', 10],
301
+
302
+ ['Z', 35],
303
+ ['y', 34],
304
+ ['X', 33],
305
+ ['w', 32],
306
+ ['V', 31],
307
+ ['u', 30],
308
+ ['T', 29],
309
+ ['s', 28],
310
+ ['R', 27],
311
+ ['q', 26],
312
+ ['P', 25],
313
+ ['o', 24],
314
+ ['N', 23],
315
+ ['m', 22],
316
+ ['L', 21],
317
+ ['k', 20],
318
+ ['J', 19],
319
+ ['i', 18],
320
+ ['H', 17],
321
+ ['g', 16],
322
+ ['F', 15],
323
+ ['e', 14],
324
+ ['D', 13],
325
+ ['c', 12],
326
+ ['B', 11],
327
+ ['a', 10],
328
+ ['9', 9],
329
+ ['8', 8],
330
+ ['7', 7],
331
+ ['6', 6],
332
+ ['5', 5],
333
+ ['4', 4],
334
+ ['3', 3],
335
+ ['2', 2]
336
+ ];
337
+ }
338
+
339
+ /**
340
+ * @dataProvider providerFromBaseWithInvalidBase
341
+ */
342
+ public function testFromBaseWithInvalidBase(int $base) : void
343
+ {
344
+ $this->expectException(\InvalidArgumentException::class);
345
+ BigInteger::fromBase('0', $base);
346
+ }
347
+
348
+ public function providerFromBaseWithInvalidBase() : array
349
+ {
350
+ return [
351
+ [-2],
352
+ [-1],
353
+ [0],
354
+ [1],
355
+ [37]
356
+ ];
357
+ }
358
+
359
+ public function testZero() : void
360
+ {
361
+ self::assertBigIntegerEquals('0', BigInteger::zero());
362
+ self::assertSame(BigInteger::zero(), BigInteger::zero());
363
+ }
364
+
365
+ public function testOne() : void
366
+ {
367
+ self::assertBigIntegerEquals('1', BigInteger::one());
368
+ self::assertSame(BigInteger::one(), BigInteger::one());
369
+ }
370
+
371
+ public function testTen() : void
372
+ {
373
+ self::assertBigIntegerEquals('10', BigInteger::ten());
374
+ self::assertSame(BigInteger::ten(), BigInteger::ten());
375
+ }
376
+
377
+ /**
378
+ * @param string[] $values
379
+ *
380
+ * @dataProvider providerGcdMultiple
381
+ */
382
+ public function testGcdMultiple(array $values, string $expectedGCD): void
383
+ {
384
+ $values = array_map(fn (string $value) => BigInteger::of($value), $values);
385
+ $actualGCD = BigInteger::gcdMultiple(...$values);
386
+
387
+ self::assertSame($expectedGCD, (string) $actualGCD);
388
+ }
389
+
390
+ public function providerGcdMultiple(): Generator
391
+ {
392
+ // 1 value
393
+ foreach (['-2', '-1', '0', '1', '2'] as $value) {
394
+ yield [[$value], $value];
395
+ }
396
+
397
+ // 2 values
398
+ foreach ($this->providerGcd() as [$a, $b, $gcd]) {
399
+ yield [[$a, $b], $gcd];
400
+ }
401
+
402
+ // n values
403
+ yield [['2', '4', '7'], '1'];
404
+ yield [['2', '4', '8'], '2'];
405
+ yield [['2', '4', '-7'], '1'];
406
+ yield [['2', '4', '-8'], '2'];
407
+ yield [['28', '56', '77777'], '7'];
408
+ yield [['28', '56', '77778'], '2'];
409
+ yield [['28', '56', '77782'], '2'];
410
+ yield [['28', '56', '77783'], '1'];
411
+ yield [['28', '56', '77784'], '28'];
412
+ yield [['28', '56', '77784', '4'], '4'];
413
+ yield [['28', '56', '77784', '14'], '14'];
414
+ yield [['28', '56', '77784', '14', '4'], '2'];
415
+ }
416
+
417
+ /**
418
+ * @dataProvider providerMin
419
+ *
420
+ * @param array $values The values to compare.
421
+ * @param string $min The expected minimum value.
422
+ */
423
+ public function testMin(array $values, string $min) : void
424
+ {
425
+ self::assertBigIntegerEquals($min, BigInteger::min(... $values));
426
+ }
427
+
428
+ public function providerMin() : array
429
+ {
430
+ return [
431
+ [[0, 1, -1], '-1'],
432
+ [[0, '10', '5989'], '0'],
433
+ [[0, '10', '5989', '-1.00'], '-1'],
434
+ [['-2/2', '1'], '-1'],
435
+ [['-1.0', '1', '2', '-300/4', '-100'], '-100'],
436
+ [['999999999999999999999999999', '1000000000000000000000000000'], '999999999999999999999999999'],
437
+ [['-999999999999999999999999999', '-1000000000000000000000000000'], '-1000000000000000000000000000']
438
+ ];
439
+ }
440
+
441
+ public function testMinOfZeroValuesThrowsException() : void
442
+ {
443
+ $this->expectException(\InvalidArgumentException::class);
444
+ BigInteger::min();
445
+ }
446
+
447
+ public function testMinOfNonIntegerValuesThrowsException() : void
448
+ {
449
+ $this->expectException(RoundingNecessaryException::class);
450
+ BigInteger::min(1, 1.2);
451
+ }
452
+
453
+ /**
454
+ * @dataProvider providerMax
455
+ *
456
+ * @param array $values The values to compare.
457
+ * @param string $max The expected maximum value.
458
+ */
459
+ public function testMax(array $values, string $max) : void
460
+ {
461
+ self::assertBigIntegerEquals($max, BigInteger::max(... $values));
462
+ }
463
+
464
+ public function providerMax() : array
465
+ {
466
+ return [
467
+ [[0, 1, -1], '1'],
468
+ [[0, '10', '5989.0'], '5989'],
469
+ [[0, '10', '5989', '-1'], '5989'],
470
+ [[0, '10', '5989', '-1', 6000.0], '6000'],
471
+ [['-1', '0'], '0'],
472
+ [['-1', '1', '2', '27/9', '-100'], '3'],
473
+ [['999999999999999999999999999', '1000000000000000000000000000'], '1000000000000000000000000000'],
474
+ [['-999999999999999999999999999', '-1000000000000000000000000000'], '-999999999999999999999999999']
475
+ ];
476
+ }
477
+
478
+ public function testMaxOfZeroValuesThrowsException() : void
479
+ {
480
+ $this->expectException(\InvalidArgumentException::class);
481
+ BigInteger::max();
482
+ }
483
+
484
+ public function testMaxOfNonIntegerValuesThrowsException() : void
485
+ {
486
+ $this->expectException(RoundingNecessaryException::class);
487
+ BigInteger::max(1, '3/2');
488
+ }
489
+
490
+ /**
491
+ * @dataProvider providerSum
492
+ *
493
+ * @param array $values The values to add.
494
+ * @param string $sum The expected sum.
495
+ */
496
+ public function testSum(array $values, string $sum) : void
497
+ {
498
+ self::assertBigIntegerEquals($sum, BigInteger::sum(... $values));
499
+ }
500
+
501
+ public function providerSum() : array
502
+ {
503
+ return [
504
+ [[-1], '-1'],
505
+ [[0, 1, -1], '0'],
506
+ [[0, '10', '5989.0'], '5999'],
507
+ [[0, '10', '5989', '-1'], '5998'],
508
+ [[0, '10', '5989', '-1', 6000.0], '11998'],
509
+ [['-1', '0'], '-1'],
510
+ [['-1', '1', '2', '27/9', '-100'], '-95'],
511
+ [['1234567', '-1233.00', 137, '406847567975012457258945126', ], '406847567975012457260178597'],
512
+ [['-165504564654654879742303821254754', '-4455454', 455879563], '-165504564654654879742303369830645']
513
+ ];
514
+ }
515
+
516
+ public function testSumOfZeroValuesThrowsException() : void
517
+ {
518
+ $this->expectException(\InvalidArgumentException::class);
519
+ BigInteger::sum();
520
+ }
521
+
522
+ public function testSumOfNonIntegerValuesThrowsException() : void
523
+ {
524
+ $this->expectException(RoundingNecessaryException::class);
525
+ BigInteger::sum(1, '3/2');
526
+ }
527
+
528
+ /**
529
+ * @dataProvider providerPlus
530
+ *
531
+ * @param string $a The base number.
532
+ * @param string $b The number to add.
533
+ * @param string $r The expected result.
534
+ */
535
+ public function testPlus(string $a, string $b, string $r) : void
536
+ {
537
+ self::assertBigIntegerEquals($r, BigInteger::of($a)->plus($b));
538
+ }
539
+
540
+ public function providerPlus() : array
541
+ {
542
+ return [
543
+ ['5165450198704521651351654564564089798441', '0', '5165450198704521651351654564564089798441'],
544
+ ['-5165450198704521651351654564564089798441', '0', '-5165450198704521651351654564564089798441'],
545
+ ['0', '5165450198704521651351654564564089798441', '5165450198704521651351654564564089798441'],
546
+ ['0', '-5165450198704521651351654564564089798441', '-5165450198704521651351654564564089798441'],
547
+ ['5165450198704521651351654564564089798441', '-5165450198704521651351654564564089798441', '0'],
548
+ ['-5165450198704521651351654564564089798441', '5165450198704521651351654564564089798441', '0'],
549
+
550
+ ['3493049309220392055810', '9918493493849898938928310121', '9918496986899208159320365931'],
551
+ ['546254089287665464650654', '-4654654565726542654005465', '-4108400476438877189354811'],
552
+ ['-54654654625426504062224', '406546504670332465465435004', '406491850015707038961372780'],
553
+ ['-78706406576549688403246', '-3064672987984605465406546', '-3143379394561155153809792']
554
+ ];
555
+ }
556
+
557
+ /**
558
+ * @dataProvider providerMinus
559
+ *
560
+ * @param string $a The base number.
561
+ * @param string $b The number to subtract.
562
+ * @param string $r The expected result.
563
+ */
564
+ public function testMinus(string $a, string $b, string $r) : void
565
+ {
566
+ self::assertBigIntegerEquals($r, BigInteger::of($a)->minus($b));
567
+ }
568
+
569
+ public function providerMinus() : array
570
+ {
571
+ return [
572
+ ['5165450198704521651351654564564089798441', '0', '5165450198704521651351654564564089798441'],
573
+ ['-5165450198704521651351654564564089798441', '0', '-5165450198704521651351654564564089798441'],
574
+ ['0', '5165450198704521651351654564564089798441', '-5165450198704521651351654564564089798441'],
575
+ ['0', '-5165450198704521651351654564564089798441', '5165450198704521651351654564564089798441'],
576
+
577
+ ['879798276565798787646', '2345178709879804654605406456', '-2345177830081528088806618810'],
578
+ ['99465465545004066406868767', '-79870987954654608076067608768', '79970453420199612142474477535'],
579
+ ['-46465465478979879230745664', '21316504468760001807687078994', '-21362969934238981686917824658'],
580
+ ['-2154799048440940949896046', '-9000454956465465424345404846624', '9000452801666416983404454950578']
581
+ ];
582
+ }
583
+
584
+ /**
585
+ * @dataProvider providerMultipliedBy
586
+ *
587
+ * @param string $a The base number.
588
+ * @param string|int $b The number to multiply.
589
+ * @param string $r The expected result.
590
+ */
591
+ public function testMultipliedBy(string $a, $b, string $r) : void
592
+ {
593
+ self::assertBigIntegerEquals($r, BigInteger::of($a)->multipliedBy($b));
594
+ }
595
+
596
+ public function providerMultipliedBy() : array
597
+ {
598
+ return [
599
+ ['123456789098765432101234567890987654321', '1', '123456789098765432101234567890987654321'],
600
+ ['123456789098765432101234567890987654321', '-1', '-123456789098765432101234567890987654321'],
601
+ ['1', '123456789098765432101234567890987654321', '123456789098765432101234567890987654321'],
602
+ ['15892588375910581333', '2485910409339228962451', '39507550875019745254366764864945838527183'],
603
+ ['341581435989834012309', '-91050393818389238433', '-31101124267925302088072082300643257871797'],
604
+ ['-1204902920503999920003', '1984389583950290232332', '-2390996805119422027350037939263960284136996'],
605
+ ['-991230349304902390122', '-3483910549230593053437', '3453357870660875087266990729629471366949314'],
606
+ ['0', '-3483910549230593053437', '0'],
607
+ ['-991230349304902390122', '0', '0'],
608
+
609
+
610
+ ['1274837942798479387498237897498734984', 30, '38245138283954381624947136924962049520'],
611
+ ['1274837942798479387498237897498734984', 30.0, '38245138283954381624947136924962049520'],
612
+ ['1274837942798479387498237897498734984', '30', '38245138283954381624947136924962049520'],
613
+ ['1274837942798479387498237897498734984', '30.0', '38245138283954381624947136924962049520'],
614
+ ['1274837942798479387498237897498734984', '90/3', '38245138283954381624947136924962049520'],
615
+ ];
616
+ }
617
+
618
+ /**
619
+ * @dataProvider providerDividedBy
620
+ *
621
+ * @param string $number The base number.
622
+ * @param string|int|float $divisor The divisor.
623
+ * @param string $expected The expected result, or a class name if an exception is expected.
624
+ */
625
+ public function testDividedBy(string $number, $divisor, string $expected) : void
626
+ {
627
+ $number = BigInteger::of($number);
628
+
629
+ if (self::isException($expected)) {
630
+ $this->expectException($expected);
631
+ }
632
+
633
+ $actual = $number->dividedBy($divisor);
634
+
635
+ if (! self::isException($expected)) {
636
+ self::assertBigIntegerEquals($expected, $actual);
637
+ }
638
+ }
639
+
640
+ public function providerDividedBy() : array
641
+ {
642
+ return [
643
+ ['123456789098765432101234567890987654321', 1, '123456789098765432101234567890987654321'],
644
+ ['123456789098765432101234567890987654321', 2, RoundingNecessaryException::class],
645
+ ['123456789098765432101234567890987654321', 0, DivisionByZeroException::class],
646
+ ['123456789098765432101234567890987654321', 0.0, DivisionByZeroException::class],
647
+ ['123456789098765432101234567890987654321', 0.1, RoundingNecessaryException::class],
648
+ ['123456789098765432101234567890987654322', 2, '61728394549382716050617283945493827161'],
649
+ ['123456789098765432101234567890987654322', 2.0, '61728394549382716050617283945493827161'],
650
+ ['123456789098765432101234567890987654322', '2', '61728394549382716050617283945493827161'],
651
+ ['123456789098765432101234567890987654322', '2.0', '61728394549382716050617283945493827161'],
652
+ ['123456789098765432101234567890987654322', '14/7', '61728394549382716050617283945493827161'],
653
+ ['61728394549382716050617283945493827161', '0.5', RoundingNecessaryException::class],
654
+ ['61728394549382716050617283945493827161', '1/2', RoundingNecessaryException::class],
655
+ ['0', '61728394549382716050617283945493827161', '0'],
656
+
657
+ // overflowing native integer division
658
+ ['-2147483648', '-1', '2147483648'], // 32-bit
659
+ ['-9223372036854775808', '-1', '9223372036854775808'], // 64-bit
660
+ ];
661
+ }
662
+
663
+ public function testDividedByWithInvalidRoundingModeThrowsException() : void
664
+ {
665
+ $this->expectException(\InvalidArgumentException::class);
666
+ BigInteger::of(1)->dividedBy(2, -1);
667
+ }
668
+
669
+ /**
670
+ * @dataProvider providerDividedByWithRoundingMode
671
+ *
672
+ * @param int $roundingMode The rounding mode.
673
+ * @param string $number The number to round.
674
+ * @param string|null $ten The expected rounding divided by 10, or null if an exception is expected.
675
+ * @param string|null $hundred The expected rounding divided by 100 or null if an exception is expected.
676
+ * @param string|null $thousand The expected rounding divided by 1000, or null if an exception is expected.
677
+ */
678
+ public function testDividedByWithRoundingMode(int $roundingMode, string $number, ?string $ten, ?string $hundred, ?string $thousand) : void
679
+ {
680
+ $number = BigInteger::of($number);
681
+
682
+ $this->doTestDividedByWithRoundingMode($roundingMode, $number, '1', $ten, $hundred, $thousand);
683
+ $this->doTestDividedByWithRoundingMode($roundingMode, $number->negated(), '-1', $ten, $hundred, $thousand);
684
+ }
685
+
686
+ /**
687
+ * @param int $roundingMode The rounding mode.
688
+ * @param BigInteger $number The number to round.
689
+ * @param string $divisor The divisor.
690
+ * @param string|null $ten The expected rounding to a scale of two, or null if an exception is expected.
691
+ * @param string|null $hundred The expected rounding to a scale of one, or null if an exception is expected.
692
+ * @param string|null $thousand The expected rounding to a scale of zero, or null if an exception is expected.
693
+ */
694
+ private function doTestDividedByWithRoundingMode(int $roundingMode, BigInteger $number, string $divisor, ?string $ten, ?string $hundred, ?string $thousand) : void
695
+ {
696
+ foreach ([$ten, $hundred, $thousand] as $expected) {
697
+ $divisor .= '0';
698
+
699
+ if ($expected === null) {
700
+ $this->expectException(RoundingNecessaryException::class);
701
+ }
702
+
703
+ $actual = $number->dividedBy($divisor, $roundingMode);
704
+
705
+ if ($expected !== null) {
706
+ self::assertBigIntegerEquals($expected, $actual);
707
+ }
708
+ }
709
+ }
710
+
711
+ public function providerDividedByWithRoundingMode() : array
712
+ {
713
+ return [
714
+ [RoundingMode::UP, '3501', '351', '36', '4'],
715
+ [RoundingMode::UP, '3500', '350', '35', '4'],
716
+ [RoundingMode::UP, '3499', '350', '35', '4'],
717
+ [RoundingMode::UP, '3001', '301', '31', '4'],
718
+ [RoundingMode::UP, '3000', '300', '30', '3'],
719
+ [RoundingMode::UP, '2999', '300', '30', '3'],
720
+ [RoundingMode::UP, '2501', '251', '26', '3'],
721
+ [RoundingMode::UP, '2500', '250', '25', '3'],
722
+ [RoundingMode::UP, '2499', '250', '25', '3'],
723
+ [RoundingMode::UP, '2001', '201', '21', '3'],
724
+ [RoundingMode::UP, '2000', '200', '20', '2'],
725
+ [RoundingMode::UP, '1999', '200', '20', '2'],
726
+ [RoundingMode::UP, '1501', '151', '16', '2'],
727
+ [RoundingMode::UP, '1500', '150', '15', '2'],
728
+ [RoundingMode::UP, '1499', '150', '15', '2'],
729
+ [RoundingMode::UP, '1001', '101', '11', '2'],
730
+ [RoundingMode::UP, '1000', '100', '10', '1'],
731
+ [RoundingMode::UP, '999', '100', '10', '1'],
732
+ [RoundingMode::UP, '501', '51', '6', '1'],
733
+ [RoundingMode::UP, '500', '50', '5', '1'],
734
+ [RoundingMode::UP, '499', '50', '5', '1'],
735
+ [RoundingMode::UP, '1', '1', '1', '1'],
736
+ [RoundingMode::UP, '0', '0', '0', '0'],
737
+ [RoundingMode::UP, '-1', '-1', '-1', '-1'],
738
+ [RoundingMode::UP, '-499', '-50', '-5', '-1'],
739
+ [RoundingMode::UP, '-500', '-50', '-5', '-1'],
740
+ [RoundingMode::UP, '-501', '-51', '-6', '-1'],
741
+ [RoundingMode::UP, '-999', '-100', '-10', '-1'],
742
+ [RoundingMode::UP, '-1000', '-100', '-10', '-1'],
743
+ [RoundingMode::UP, '-1001', '-101', '-11', '-2'],
744
+ [RoundingMode::UP, '-1499', '-150', '-15', '-2'],
745
+ [RoundingMode::UP, '-1500', '-150', '-15', '-2'],
746
+ [RoundingMode::UP, '-1501', '-151', '-16', '-2'],
747
+ [RoundingMode::UP, '-1999', '-200', '-20', '-2'],
748
+ [RoundingMode::UP, '-2000', '-200', '-20', '-2'],
749
+ [RoundingMode::UP, '-2001', '-201', '-21', '-3'],
750
+ [RoundingMode::UP, '-2499', '-250', '-25', '-3'],
751
+ [RoundingMode::UP, '-2500', '-250', '-25', '-3'],
752
+ [RoundingMode::UP, '-2501', '-251', '-26', '-3'],
753
+ [RoundingMode::UP, '-2999', '-300', '-30', '-3'],
754
+ [RoundingMode::UP, '-3000', '-300', '-30', '-3'],
755
+ [RoundingMode::UP, '-3001', '-301', '-31', '-4'],
756
+ [RoundingMode::UP, '-3499', '-350', '-35', '-4'],
757
+ [RoundingMode::UP, '-3500', '-350', '-35', '-4'],
758
+ [RoundingMode::UP, '-3501', '-351', '-36', '-4'],
759
+
760
+ [RoundingMode::DOWN, '3501', '350', '35', '3'],
761
+ [RoundingMode::DOWN, '3500', '350', '35', '3'],
762
+ [RoundingMode::DOWN, '3499', '349', '34', '3'],
763
+ [RoundingMode::DOWN, '3001', '300', '30', '3'],
764
+ [RoundingMode::DOWN, '3000', '300', '30', '3'],
765
+ [RoundingMode::DOWN, '2999', '299', '29', '2'],
766
+ [RoundingMode::DOWN, '2501', '250', '25', '2'],
767
+ [RoundingMode::DOWN, '2500', '250', '25', '2'],
768
+ [RoundingMode::DOWN, '2499', '249', '24', '2'],
769
+ [RoundingMode::DOWN, '2001', '200', '20', '2'],
770
+ [RoundingMode::DOWN, '2000', '200', '20', '2'],
771
+ [RoundingMode::DOWN, '1999', '199', '19', '1'],
772
+ [RoundingMode::DOWN, '1501', '150', '15', '1'],
773
+ [RoundingMode::DOWN, '1500', '150', '15', '1'],
774
+ [RoundingMode::DOWN, '1499', '149', '14', '1'],
775
+ [RoundingMode::DOWN, '1001', '100', '10', '1'],
776
+ [RoundingMode::DOWN, '1000', '100', '10', '1'],
777
+ [RoundingMode::DOWN, '999', '99', '9', '0'],
778
+ [RoundingMode::DOWN, '501', '50', '5', '0'],
779
+ [RoundingMode::DOWN, '500', '50', '5', '0'],
780
+ [RoundingMode::DOWN, '499', '49', '4', '0'],
781
+ [RoundingMode::DOWN, '1', '0', '0', '0'],
782
+ [RoundingMode::DOWN, '0', '0', '0', '0'],
783
+ [RoundingMode::DOWN, '-1', '0', '0', '0'],
784
+ [RoundingMode::DOWN, '-499', '-49', '-4', '0'],
785
+ [RoundingMode::DOWN, '-500', '-50', '-5', '0'],
786
+ [RoundingMode::DOWN, '-501', '-50', '-5', '0'],
787
+ [RoundingMode::DOWN, '-999', '-99', '-9', '0'],
788
+ [RoundingMode::DOWN, '-1000', '-100', '-10', '-1'],
789
+ [RoundingMode::DOWN, '-1001', '-100', '-10', '-1'],
790
+ [RoundingMode::DOWN, '-1499', '-149', '-14', '-1'],
791
+ [RoundingMode::DOWN, '-1500', '-150', '-15', '-1'],
792
+ [RoundingMode::DOWN, '-1501', '-150', '-15', '-1'],
793
+ [RoundingMode::DOWN, '-1999', '-199', '-19', '-1'],
794
+ [RoundingMode::DOWN, '-2000', '-200', '-20', '-2'],
795
+ [RoundingMode::DOWN, '-2001', '-200', '-20', '-2'],
796
+ [RoundingMode::DOWN, '-2499', '-249', '-24', '-2'],
797
+ [RoundingMode::DOWN, '-2500', '-250', '-25', '-2'],
798
+ [RoundingMode::DOWN, '-2501', '-250', '-25', '-2'],
799
+ [RoundingMode::DOWN, '-2999', '-299', '-29', '-2'],
800
+ [RoundingMode::DOWN, '-3000', '-300', '-30', '-3'],
801
+ [RoundingMode::DOWN, '-3001', '-300', '-30', '-3'],
802
+ [RoundingMode::DOWN, '-3499', '-349', '-34', '-3'],
803
+ [RoundingMode::DOWN, '-3500', '-350', '-35', '-3'],
804
+ [RoundingMode::DOWN, '-3501', '-350', '-35', '-3'],
805
+
806
+ [RoundingMode::CEILING, '3501', '351', '36', '4'],
807
+ [RoundingMode::CEILING, '3500', '350', '35', '4'],
808
+ [RoundingMode::CEILING, '3499', '350', '35', '4'],
809
+ [RoundingMode::CEILING, '3001', '301', '31', '4'],
810
+ [RoundingMode::CEILING, '3000', '300', '30', '3'],
811
+ [RoundingMode::CEILING, '2999', '300', '30', '3'],
812
+ [RoundingMode::CEILING, '2501', '251', '26', '3'],
813
+ [RoundingMode::CEILING, '2500', '250', '25', '3'],
814
+ [RoundingMode::CEILING, '2499', '250', '25', '3'],
815
+ [RoundingMode::CEILING, '2001', '201', '21', '3'],
816
+ [RoundingMode::CEILING, '2000', '200', '20', '2'],
817
+ [RoundingMode::CEILING, '1999', '200', '20', '2'],
818
+ [RoundingMode::CEILING, '1501', '151', '16', '2'],
819
+ [RoundingMode::CEILING, '1500', '150', '15', '2'],
820
+ [RoundingMode::CEILING, '1499', '150', '15', '2'],
821
+ [RoundingMode::CEILING, '1001', '101', '11', '2'],
822
+ [RoundingMode::CEILING, '1000', '100', '10', '1'],
823
+ [RoundingMode::CEILING, '999', '100', '10', '1'],
824
+ [RoundingMode::CEILING, '501', '51', '6', '1'],
825
+ [RoundingMode::CEILING, '500', '50', '5', '1'],
826
+ [RoundingMode::CEILING, '499', '50', '5', '1'],
827
+ [RoundingMode::CEILING, '1', '1', '1', '1'],
828
+ [RoundingMode::CEILING, '0', '0', '0', '0'],
829
+ [RoundingMode::CEILING, '-1', '0', '0', '0'],
830
+ [RoundingMode::CEILING, '-499', '-49' , '-4', '0'],
831
+ [RoundingMode::CEILING, '-500', '-50' , '-5', '0'],
832
+ [RoundingMode::CEILING, '-501', '-50', '-5', '0'],
833
+ [RoundingMode::CEILING, '-999', '-99', '-9', '0'],
834
+ [RoundingMode::CEILING, '-1000', '-100', '-10', '-1'],
835
+ [RoundingMode::CEILING, '-1001', '-100', '-10', '-1'],
836
+ [RoundingMode::CEILING, '-1499', '-149', '-14', '-1'],
837
+ [RoundingMode::CEILING, '-1500', '-150', '-15', '-1'],
838
+ [RoundingMode::CEILING, '-1501', '-150', '-15', '-1'],
839
+ [RoundingMode::CEILING, '-1999', '-199', '-19', '-1'],
840
+ [RoundingMode::CEILING, '-2000', '-200', '-20', '-2'],
841
+ [RoundingMode::CEILING, '-2001', '-200', '-20', '-2'],
842
+ [RoundingMode::CEILING, '-2499', '-249', '-24', '-2'],
843
+ [RoundingMode::CEILING, '-2500', '-250', '-25', '-2'],
844
+ [RoundingMode::CEILING, '-2501', '-250', '-25', '-2'],
845
+ [RoundingMode::CEILING, '-2999', '-299', '-29', '-2'],
846
+ [RoundingMode::CEILING, '-3000', '-300', '-30', '-3'],
847
+ [RoundingMode::CEILING, '-3001', '-300', '-30', '-3'],
848
+ [RoundingMode::CEILING, '-3499', '-349', '-34', '-3'],
849
+ [RoundingMode::CEILING, '-3500', '-350', '-35', '-3'],
850
+ [RoundingMode::CEILING, '-3501', '-350', '-35', '-3'],
851
+
852
+ [RoundingMode::FLOOR, '3501', '350', '35', '3'],
853
+ [RoundingMode::FLOOR, '3500', '350', '35', '3'],
854
+ [RoundingMode::FLOOR, '3499', '349', '34', '3'],
855
+ [RoundingMode::FLOOR, '3001', '300', '30', '3'],
856
+ [RoundingMode::FLOOR, '3000', '300', '30', '3'],
857
+ [RoundingMode::FLOOR, '2999', '299', '29', '2'],
858
+ [RoundingMode::FLOOR, '2501', '250', '25', '2'],
859
+ [RoundingMode::FLOOR, '2500', '250', '25', '2'],
860
+ [RoundingMode::FLOOR, '2499', '249', '24', '2'],
861
+ [RoundingMode::FLOOR, '2001', '200', '20', '2'],
862
+ [RoundingMode::FLOOR, '2000', '200', '20', '2'],
863
+ [RoundingMode::FLOOR, '1999', '199', '19', '1'],
864
+ [RoundingMode::FLOOR, '1501', '150', '15', '1'],
865
+ [RoundingMode::FLOOR, '1500', '150', '15', '1'],
866
+ [RoundingMode::FLOOR, '1499', '149', '14', '1'],
867
+ [RoundingMode::FLOOR, '1001', '100', '10', '1'],
868
+ [RoundingMode::FLOOR, '1000', '100', '10', '1'],
869
+ [RoundingMode::FLOOR, '999', '99', '9', '0'],
870
+ [RoundingMode::FLOOR, '501', '50', '5', '0'],
871
+ [RoundingMode::FLOOR, '500', '50', '5', '0'],
872
+ [RoundingMode::FLOOR, '499', '49', '4', '0'],
873
+ [RoundingMode::FLOOR, '1', '0', '0', '0'],
874
+ [RoundingMode::FLOOR, '0', '0', '0', '0'],
875
+ [RoundingMode::FLOOR, '-1', '-1', '-1', '-1'],
876
+ [RoundingMode::FLOOR, '-499', '-50', '-5', '-1'],
877
+ [RoundingMode::FLOOR, '-500', '-50', '-5', '-1'],
878
+ [RoundingMode::FLOOR, '-501', '-51', '-6', '-1'],
879
+ [RoundingMode::FLOOR, '-999', '-100', '-10', '-1'],
880
+ [RoundingMode::FLOOR, '-1000', '-100', '-10', '-1'],
881
+ [RoundingMode::FLOOR, '-1001', '-101', '-11', '-2'],
882
+ [RoundingMode::FLOOR, '-1499', '-150', '-15', '-2'],
883
+ [RoundingMode::FLOOR, '-1500', '-150', '-15', '-2'],
884
+ [RoundingMode::FLOOR, '-1501', '-151', '-16', '-2'],
885
+ [RoundingMode::FLOOR, '-1999', '-200', '-20', '-2'],
886
+ [RoundingMode::FLOOR, '-2000', '-200', '-20', '-2'],
887
+ [RoundingMode::FLOOR, '-2001', '-201', '-21', '-3'],
888
+ [RoundingMode::FLOOR, '-2499', '-250', '-25', '-3'],
889
+ [RoundingMode::FLOOR, '-2500', '-250', '-25', '-3'],
890
+ [RoundingMode::FLOOR, '-2501', '-251', '-26', '-3'],
891
+ [RoundingMode::FLOOR, '-2999', '-300', '-30', '-3'],
892
+ [RoundingMode::FLOOR, '-3000', '-300', '-30', '-3'],
893
+ [RoundingMode::FLOOR, '-3001', '-301', '-31', '-4'],
894
+ [RoundingMode::FLOOR, '-3499', '-350', '-35', '-4'],
895
+ [RoundingMode::FLOOR, '-3500', '-350', '-35', '-4'],
896
+ [RoundingMode::FLOOR, '-3501', '-351', '-36', '-4'],
897
+
898
+ [RoundingMode::HALF_UP, '3501', '350', '35', '4'],
899
+ [RoundingMode::HALF_UP, '3500', '350', '35', '4'],
900
+ [RoundingMode::HALF_UP, '3499', '350', '35', '3'],
901
+ [RoundingMode::HALF_UP, '3001', '300', '30', '3'],
902
+ [RoundingMode::HALF_UP, '3000', '300', '30', '3'],
903
+ [RoundingMode::HALF_UP, '2999', '300', '30', '3'],
904
+ [RoundingMode::HALF_UP, '2501', '250', '25', '3'],
905
+ [RoundingMode::HALF_UP, '2500', '250', '25', '3'],
906
+ [RoundingMode::HALF_UP, '2499', '250', '25', '2'],
907
+ [RoundingMode::HALF_UP, '2001', '200', '20', '2'],
908
+ [RoundingMode::HALF_UP, '2000', '200', '20', '2'],
909
+ [RoundingMode::HALF_UP, '1999', '200', '20', '2'],
910
+ [RoundingMode::HALF_UP, '1501', '150', '15', '2'],
911
+ [RoundingMode::HALF_UP, '1500', '150', '15', '2'],
912
+ [RoundingMode::HALF_UP, '1499', '150', '15', '1'],
913
+ [RoundingMode::HALF_UP, '1001', '100', '10', '1'],
914
+ [RoundingMode::HALF_UP, '1000', '100', '10', '1'],
915
+ [RoundingMode::HALF_UP, '999', '100', '10', '1'],
916
+ [RoundingMode::HALF_UP, '501', '50', '5', '1'],
917
+ [RoundingMode::HALF_UP, '500', '50', '5', '1'],
918
+ [RoundingMode::HALF_UP, '499', '50', '5', '0'],
919
+ [RoundingMode::HALF_UP, '1', '0', '0', '0'],
920
+ [RoundingMode::HALF_UP, '0', '0', '0', '0'],
921
+ [RoundingMode::HALF_UP, '-1', '0', '0', '0'],
922
+ [RoundingMode::HALF_UP, '-499', '-50', '-5', '0'],
923
+ [RoundingMode::HALF_UP, '-500', '-50', '-5', '-1'],
924
+ [RoundingMode::HALF_UP, '-501', '-50', '-5', '-1'],
925
+ [RoundingMode::HALF_UP, '-999', '-100', '-10', '-1'],
926
+ [RoundingMode::HALF_UP, '-1000', '-100', '-10', '-1'],
927
+ [RoundingMode::HALF_UP, '-1001', '-100', '-10', '-1'],
928
+ [RoundingMode::HALF_UP, '-1499', '-150', '-15', '-1'],
929
+ [RoundingMode::HALF_UP, '-1500', '-150', '-15', '-2'],
930
+ [RoundingMode::HALF_UP, '-1501', '-150', '-15', '-2'],
931
+ [RoundingMode::HALF_UP, '-1999', '-200', '-20', '-2'],
932
+ [RoundingMode::HALF_UP, '-2000', '-200', '-20', '-2'],
933
+ [RoundingMode::HALF_UP, '-2001', '-200', '-20', '-2'],
934
+ [RoundingMode::HALF_UP, '-2499', '-250', '-25', '-2'],
935
+ [RoundingMode::HALF_UP, '-2500', '-250', '-25', '-3'],
936
+ [RoundingMode::HALF_UP, '-2501', '-250', '-25', '-3'],
937
+ [RoundingMode::HALF_UP, '-2999', '-300', '-30', '-3'],
938
+ [RoundingMode::HALF_UP, '-3000', '-300', '-30', '-3'],
939
+ [RoundingMode::HALF_UP, '-3001', '-300', '-30', '-3'],
940
+ [RoundingMode::HALF_UP, '-3499', '-350', '-35', '-3'],
941
+ [RoundingMode::HALF_UP, '-3500', '-350', '-35', '-4'],
942
+ [RoundingMode::HALF_UP, '-3501', '-350', '-35', '-4'],
943
+
944
+ [RoundingMode::HALF_DOWN, '3501', '350', '35', '4'],
945
+ [RoundingMode::HALF_DOWN, '3500', '350', '35', '3'],
946
+ [RoundingMode::HALF_DOWN, '3499', '350', '35', '3'],
947
+ [RoundingMode::HALF_DOWN, '3001', '300', '30', '3'],
948
+ [RoundingMode::HALF_DOWN, '3000', '300', '30', '3'],
949
+ [RoundingMode::HALF_DOWN, '2999', '300', '30', '3'],
950
+ [RoundingMode::HALF_DOWN, '2501', '250', '25', '3'],
951
+ [RoundingMode::HALF_DOWN, '2500', '250', '25', '2'],
952
+ [RoundingMode::HALF_DOWN, '2499', '250', '25', '2'],
953
+ [RoundingMode::HALF_DOWN, '2001', '200', '20', '2'],
954
+ [RoundingMode::HALF_DOWN, '2000', '200', '20', '2'],
955
+ [RoundingMode::HALF_DOWN, '1999', '200', '20', '2'],
956
+ [RoundingMode::HALF_DOWN, '1501', '150', '15', '2'],
957
+ [RoundingMode::HALF_DOWN, '1500', '150', '15', '1'],
958
+ [RoundingMode::HALF_DOWN, '1499', '150', '15', '1'],
959
+ [RoundingMode::HALF_DOWN, '1001', '100', '10', '1'],
960
+ [RoundingMode::HALF_DOWN, '1000', '100', '10', '1'],
961
+ [RoundingMode::HALF_DOWN, '999', '100', '10', '1'],
962
+ [RoundingMode::HALF_DOWN, '501', '50', '5', '1'],
963
+ [RoundingMode::HALF_DOWN, '500', '50', '5', '0'],
964
+ [RoundingMode::HALF_DOWN, '499', '50', '5', '0'],
965
+ [RoundingMode::HALF_DOWN, '1', '0', '0', '0'],
966
+ [RoundingMode::HALF_DOWN, '0', '0', '0', '0'],
967
+ [RoundingMode::HALF_DOWN, '-1', '0', '0', '0'],
968
+ [RoundingMode::HALF_DOWN, '-499', '-50', '-5', '0'],
969
+ [RoundingMode::HALF_DOWN, '-500', '-50', '-5', '0'],
970
+ [RoundingMode::HALF_DOWN, '-501', '-50', '-5', '-1'],
971
+ [RoundingMode::HALF_DOWN, '-999', '-100', '-10', '-1'],
972
+ [RoundingMode::HALF_DOWN, '-1000', '-100', '-10', '-1'],
973
+ [RoundingMode::HALF_DOWN, '-1001', '-100', '-10', '-1'],
974
+ [RoundingMode::HALF_DOWN, '-1499', '-150', '-15', '-1'],
975
+ [RoundingMode::HALF_DOWN, '-1500', '-150', '-15', '-1'],
976
+ [RoundingMode::HALF_DOWN, '-1501', '-150', '-15', '-2'],
977
+ [RoundingMode::HALF_DOWN, '-1999', '-200', '-20', '-2'],
978
+ [RoundingMode::HALF_DOWN, '-2000', '-200', '-20', '-2'],
979
+ [RoundingMode::HALF_DOWN, '-2001', '-200', '-20', '-2'],
980
+ [RoundingMode::HALF_DOWN, '-2499', '-250', '-25', '-2'],
981
+ [RoundingMode::HALF_DOWN, '-2500', '-250', '-25', '-2'],
982
+ [RoundingMode::HALF_DOWN, '-2501', '-250', '-25', '-3'],
983
+ [RoundingMode::HALF_DOWN, '-2999', '-300', '-30', '-3'],
984
+ [RoundingMode::HALF_DOWN, '-3000', '-300', '-30', '-3'],
985
+ [RoundingMode::HALF_DOWN, '-3001', '-300', '-30', '-3'],
986
+ [RoundingMode::HALF_DOWN, '-3499', '-350', '-35', '-3'],
987
+ [RoundingMode::HALF_DOWN, '-3500', '-350', '-35', '-3'],
988
+ [RoundingMode::HALF_DOWN, '-3501', '-350', '-35', '-4'],
989
+
990
+ [RoundingMode::HALF_CEILING, '3501', '350', '35', '4'],
991
+ [RoundingMode::HALF_CEILING, '3500', '350', '35', '4'],
992
+ [RoundingMode::HALF_CEILING, '3499', '350', '35', '3'],
993
+ [RoundingMode::HALF_CEILING, '3001', '300', '30', '3'],
994
+ [RoundingMode::HALF_CEILING, '3000', '300', '30', '3'],
995
+ [RoundingMode::HALF_CEILING, '2999', '300', '30', '3'],
996
+ [RoundingMode::HALF_CEILING, '2501', '250', '25', '3'],
997
+ [RoundingMode::HALF_CEILING, '2500', '250', '25', '3'],
998
+ [RoundingMode::HALF_CEILING, '2499', '250', '25', '2'],
999
+ [RoundingMode::HALF_CEILING, '2001', '200', '20', '2'],
1000
+ [RoundingMode::HALF_CEILING, '2000', '200', '20', '2'],
1001
+ [RoundingMode::HALF_CEILING, '1999', '200', '20', '2'],
1002
+ [RoundingMode::HALF_CEILING, '1501', '150', '15', '2'],
1003
+ [RoundingMode::HALF_CEILING, '1500', '150', '15', '2'],
1004
+ [RoundingMode::HALF_CEILING, '1499', '150', '15', '1'],
1005
+ [RoundingMode::HALF_CEILING, '1001', '100', '10', '1'],
1006
+ [RoundingMode::HALF_CEILING, '1000', '100', '10', '1'],
1007
+ [RoundingMode::HALF_CEILING, '999', '100', '10', '1'],
1008
+ [RoundingMode::HALF_CEILING, '501', '50', '5', '1'],
1009
+ [RoundingMode::HALF_CEILING, '500', '50', '5', '1'],
1010
+ [RoundingMode::HALF_CEILING, '499', '50', '5', '0'],
1011
+ [RoundingMode::HALF_CEILING, '1', '0', '0', '0'],
1012
+ [RoundingMode::HALF_CEILING, '0', '0', '0', '0'],
1013
+ [RoundingMode::HALF_CEILING, '-1', '0', '0', '0'],
1014
+ [RoundingMode::HALF_CEILING, '-499', '-50', '-5', '0'],
1015
+ [RoundingMode::HALF_CEILING, '-500', '-50', '-5', '0'],
1016
+ [RoundingMode::HALF_CEILING, '-501', '-50', '-5', '-1'],
1017
+ [RoundingMode::HALF_CEILING, '-999', '-100', '-10', '-1'],
1018
+ [RoundingMode::HALF_CEILING, '-1000', '-100', '-10', '-1'],
1019
+ [RoundingMode::HALF_CEILING, '-1001', '-100', '-10', '-1'],
1020
+ [RoundingMode::HALF_CEILING, '-1499', '-150', '-15', '-1'],
1021
+ [RoundingMode::HALF_CEILING, '-1500', '-150', '-15', '-1'],
1022
+ [RoundingMode::HALF_CEILING, '-1501', '-150', '-15', '-2'],
1023
+ [RoundingMode::HALF_CEILING, '-1999', '-200', '-20', '-2'],
1024
+ [RoundingMode::HALF_CEILING, '-2000', '-200', '-20', '-2'],
1025
+ [RoundingMode::HALF_CEILING, '-2001', '-200', '-20', '-2'],
1026
+ [RoundingMode::HALF_CEILING, '-2499', '-250', '-25', '-2'],
1027
+ [RoundingMode::HALF_CEILING, '-2500', '-250', '-25', '-2'],
1028
+ [RoundingMode::HALF_CEILING, '-2501', '-250', '-25', '-3'],
1029
+ [RoundingMode::HALF_CEILING, '-2999', '-300', '-30', '-3'],
1030
+ [RoundingMode::HALF_CEILING, '-3000', '-300', '-30', '-3'],
1031
+ [RoundingMode::HALF_CEILING, '-3001', '-300', '-30', '-3'],
1032
+ [RoundingMode::HALF_CEILING, '-3499', '-350', '-35', '-3'],
1033
+ [RoundingMode::HALF_CEILING, '-3500', '-350', '-35', '-3'],
1034
+ [RoundingMode::HALF_CEILING, '-3501', '-350', '-35', '-4'],
1035
+
1036
+ [RoundingMode::HALF_FLOOR, '3501', '350', '35', '4'],
1037
+ [RoundingMode::HALF_FLOOR, '3500', '350', '35', '3'],
1038
+ [RoundingMode::HALF_FLOOR, '3499', '350', '35', '3'],
1039
+ [RoundingMode::HALF_FLOOR, '3001', '300', '30', '3'],
1040
+ [RoundingMode::HALF_FLOOR, '3000', '300', '30', '3'],
1041
+ [RoundingMode::HALF_FLOOR, '2999', '300', '30', '3'],
1042
+ [RoundingMode::HALF_FLOOR, '2501', '250', '25', '3'],
1043
+ [RoundingMode::HALF_FLOOR, '2500', '250', '25', '2'],
1044
+ [RoundingMode::HALF_FLOOR, '2499', '250', '25', '2'],
1045
+ [RoundingMode::HALF_FLOOR, '2001', '200', '20', '2'],
1046
+ [RoundingMode::HALF_FLOOR, '2000', '200', '20', '2'],
1047
+ [RoundingMode::HALF_FLOOR, '1999', '200', '20', '2'],
1048
+ [RoundingMode::HALF_FLOOR, '1501', '150', '15', '2'],
1049
+ [RoundingMode::HALF_FLOOR, '1500', '150', '15', '1'],
1050
+ [RoundingMode::HALF_FLOOR, '1499', '150', '15', '1'],
1051
+ [RoundingMode::HALF_FLOOR, '1001', '100', '10', '1'],
1052
+ [RoundingMode::HALF_FLOOR, '1000', '100', '10', '1'],
1053
+ [RoundingMode::HALF_FLOOR, '999', '100', '10', '1'],
1054
+ [RoundingMode::HALF_FLOOR, '501', '50', '5', '1'],
1055
+ [RoundingMode::HALF_FLOOR, '500', '50', '5', '0'],
1056
+ [RoundingMode::HALF_FLOOR, '499', '50', '5', '0'],
1057
+ [RoundingMode::HALF_FLOOR, '1', '0', '0', '0'],
1058
+ [RoundingMode::HALF_FLOOR, '0', '0', '0', '0'],
1059
+ [RoundingMode::HALF_FLOOR, '-1', '0', '0', '0'],
1060
+ [RoundingMode::HALF_FLOOR, '-499', '-50', '-5', '0'],
1061
+ [RoundingMode::HALF_FLOOR, '-500', '-50', '-5', '-1'],
1062
+ [RoundingMode::HALF_FLOOR, '-501', '-50', '-5', '-1'],
1063
+ [RoundingMode::HALF_FLOOR, '-999', '-100', '-10', '-1'],
1064
+ [RoundingMode::HALF_FLOOR, '-1000', '-100', '-10', '-1'],
1065
+ [RoundingMode::HALF_FLOOR, '-1001', '-100', '-10', '-1'],
1066
+ [RoundingMode::HALF_FLOOR, '-1499', '-150', '-15', '-1'],
1067
+ [RoundingMode::HALF_FLOOR, '-1500', '-150', '-15', '-2'],
1068
+ [RoundingMode::HALF_FLOOR, '-1501', '-150', '-15', '-2'],
1069
+ [RoundingMode::HALF_FLOOR, '-1999', '-200', '-20', '-2'],
1070
+ [RoundingMode::HALF_FLOOR, '-2000', '-200', '-20', '-2'],
1071
+ [RoundingMode::HALF_FLOOR, '-2001', '-200', '-20', '-2'],
1072
+ [RoundingMode::HALF_FLOOR, '-2499', '-250', '-25', '-2'],
1073
+ [RoundingMode::HALF_FLOOR, '-2500', '-250', '-25', '-3'],
1074
+ [RoundingMode::HALF_FLOOR, '-2501', '-250', '-25', '-3'],
1075
+ [RoundingMode::HALF_FLOOR, '-2999', '-300', '-30', '-3'],
1076
+ [RoundingMode::HALF_FLOOR, '-3000', '-300', '-30', '-3'],
1077
+ [RoundingMode::HALF_FLOOR, '-3001', '-300', '-30', '-3'],
1078
+ [RoundingMode::HALF_FLOOR, '-3499', '-350', '-35', '-3'],
1079
+ [RoundingMode::HALF_FLOOR, '-3500', '-350', '-35', '-4'],
1080
+ [RoundingMode::HALF_FLOOR, '-3501', '-350', '-35', '-4'],
1081
+
1082
+ [RoundingMode::HALF_EVEN, '3501', '350', '35', '4'],
1083
+ [RoundingMode::HALF_EVEN, '3500', '350', '35', '4'],
1084
+ [RoundingMode::HALF_EVEN, '3499', '350', '35', '3'],
1085
+ [RoundingMode::HALF_EVEN, '3001', '300', '30', '3'],
1086
+ [RoundingMode::HALF_EVEN, '3000', '300', '30', '3'],
1087
+ [RoundingMode::HALF_EVEN, '2999', '300', '30', '3'],
1088
+ [RoundingMode::HALF_EVEN, '2501', '250', '25', '3'],
1089
+ [RoundingMode::HALF_EVEN, '2500', '250', '25', '2'],
1090
+ [RoundingMode::HALF_EVEN, '2499', '250', '25', '2'],
1091
+ [RoundingMode::HALF_EVEN, '2001', '200', '20', '2'],
1092
+ [RoundingMode::HALF_EVEN, '2000', '200', '20', '2'],
1093
+ [RoundingMode::HALF_EVEN, '1999', '200', '20', '2'],
1094
+ [RoundingMode::HALF_EVEN, '1501', '150', '15', '2'],
1095
+ [RoundingMode::HALF_EVEN, '1500', '150', '15', '2'],
1096
+ [RoundingMode::HALF_EVEN, '1499', '150', '15', '1'],
1097
+ [RoundingMode::HALF_EVEN, '1001', '100', '10', '1'],
1098
+ [RoundingMode::HALF_EVEN, '1000', '100', '10', '1'],
1099
+ [RoundingMode::HALF_EVEN, '999', '100', '10', '1'],
1100
+ [RoundingMode::HALF_EVEN, '501', '50', '5', '1'],
1101
+ [RoundingMode::HALF_EVEN, '500', '50', '5', '0'],
1102
+ [RoundingMode::HALF_EVEN, '499', '50', '5', '0'],
1103
+ [RoundingMode::HALF_EVEN, '1', '0', '0', '0'],
1104
+ [RoundingMode::HALF_EVEN, '0', '0', '0', '0'],
1105
+ [RoundingMode::HALF_EVEN, '-1', '0', '0', '0'],
1106
+ [RoundingMode::HALF_EVEN, '-499', '-50', '-5', '0'],
1107
+ [RoundingMode::HALF_EVEN, '-500', '-50', '-5', '0'],
1108
+ [RoundingMode::HALF_EVEN, '-501', '-50', '-5', '-1'],
1109
+ [RoundingMode::HALF_EVEN, '-999', '-100', '-10', '-1'],
1110
+ [RoundingMode::HALF_EVEN, '-1000', '-100', '-10', '-1'],
1111
+ [RoundingMode::HALF_EVEN, '-1001', '-100', '-10', '-1'],
1112
+ [RoundingMode::HALF_EVEN, '-1499', '-150', '-15', '-1'],
1113
+ [RoundingMode::HALF_EVEN, '-1500', '-150', '-15', '-2'],
1114
+ [RoundingMode::HALF_EVEN, '-1501', '-150', '-15', '-2'],
1115
+ [RoundingMode::HALF_EVEN, '-1999', '-200', '-20', '-2'],
1116
+ [RoundingMode::HALF_EVEN, '-2000', '-200', '-20', '-2'],
1117
+ [RoundingMode::HALF_EVEN, '-2001', '-200', '-20', '-2'],
1118
+ [RoundingMode::HALF_EVEN, '-2499', '-250', '-25', '-2'],
1119
+ [RoundingMode::HALF_EVEN, '-2500', '-250', '-25', '-2'],
1120
+ [RoundingMode::HALF_EVEN, '-2501', '-250', '-25', '-3'],
1121
+ [RoundingMode::HALF_EVEN, '-2999', '-300', '-30', '-3'],
1122
+ [RoundingMode::HALF_EVEN, '-3000', '-300', '-30', '-3'],
1123
+ [RoundingMode::HALF_EVEN, '-3001', '-300', '-30', '-3'],
1124
+ [RoundingMode::HALF_EVEN, '-3499', '-350', '-35', '-3'],
1125
+ [RoundingMode::HALF_EVEN, '-3500', '-350', '-35', '-4'],
1126
+ [RoundingMode::HALF_EVEN, '-3501', '-350', '-35', '-4'],
1127
+
1128
+ [RoundingMode::UNNECESSARY, '3501', null, null, null],
1129
+ [RoundingMode::UNNECESSARY, '3500', '350', '35', null],
1130
+ [RoundingMode::UNNECESSARY, '3499', null, null, null],
1131
+ [RoundingMode::UNNECESSARY, '3001', null, null, null],
1132
+ [RoundingMode::UNNECESSARY, '3000', '300', '30', '3'],
1133
+ [RoundingMode::UNNECESSARY, '2999', null, null, null],
1134
+ [RoundingMode::UNNECESSARY, '2501', null, null, null],
1135
+ [RoundingMode::UNNECESSARY, '2500', '250', '25', null],
1136
+ [RoundingMode::UNNECESSARY, '2499', null, null, null],
1137
+ [RoundingMode::UNNECESSARY, '2001', null, null, null],
1138
+ [RoundingMode::UNNECESSARY, '2000', '200', '20', '2'],
1139
+ [RoundingMode::UNNECESSARY, '1999', null, null, null],
1140
+ [RoundingMode::UNNECESSARY, '1501', null, null, null],
1141
+ [RoundingMode::UNNECESSARY, '1500', '150', '15', null],
1142
+ [RoundingMode::UNNECESSARY, '1499', null, null, null],
1143
+ [RoundingMode::UNNECESSARY, '1001', null, null, null],
1144
+ [RoundingMode::UNNECESSARY, '1000', '100', '10', '1'],
1145
+ [RoundingMode::UNNECESSARY, '999', null, null, null],
1146
+ [RoundingMode::UNNECESSARY, '501', null, null, null],
1147
+ [RoundingMode::UNNECESSARY, '500', '50', '5', null],
1148
+ [RoundingMode::UNNECESSARY, '499', null, null, null],
1149
+ [RoundingMode::UNNECESSARY, '1', null, null, null],
1150
+ [RoundingMode::UNNECESSARY, '0', '0', '0', '0'],
1151
+ [RoundingMode::UNNECESSARY, '-1', null, null, null],
1152
+ [RoundingMode::UNNECESSARY, '-499', null, null, null],
1153
+ [RoundingMode::UNNECESSARY, '-500', '-50', '-5', null],
1154
+ [RoundingMode::UNNECESSARY, '-501', null, null, null],
1155
+ [RoundingMode::UNNECESSARY, '-999', null, null, null],
1156
+ [RoundingMode::UNNECESSARY, '-1000', '-100', '-10', '-1'],
1157
+ [RoundingMode::UNNECESSARY, '-1001', null, null, null],
1158
+ [RoundingMode::UNNECESSARY, '-1499', null, null, null],
1159
+ [RoundingMode::UNNECESSARY, '-1500', '-150', '-15', null],
1160
+ [RoundingMode::UNNECESSARY, '-1501', null, null, null],
1161
+ [RoundingMode::UNNECESSARY, '-1999', null, null, null],
1162
+ [RoundingMode::UNNECESSARY, '-2000', '-200', '-20', '-2'],
1163
+ [RoundingMode::UNNECESSARY, '-2001', null, null, null],
1164
+ [RoundingMode::UNNECESSARY, '-2499', null, null, null],
1165
+ [RoundingMode::UNNECESSARY, '-2500', '-250', '-25', null],
1166
+ [RoundingMode::UNNECESSARY, '-2501', null, null, null],
1167
+ [RoundingMode::UNNECESSARY, '-2999', null, null, null],
1168
+ [RoundingMode::UNNECESSARY, '-3000', '-300', '-30', '-3'],
1169
+ [RoundingMode::UNNECESSARY, '-3001', null, null, null],
1170
+ [RoundingMode::UNNECESSARY, '-3499', null, null, null],
1171
+ [RoundingMode::UNNECESSARY, '-3500', '-350', '-35', null],
1172
+ [RoundingMode::UNNECESSARY, '-3501', null, null, null],
1173
+ ];
1174
+ }
1175
+
1176
+ /**
1177
+ * @dataProvider providerQuotientAndRemainder
1178
+ *
1179
+ * @param string $dividend The dividend.
1180
+ * @param string $divisor The divisor.
1181
+ * @param string $quotient The expected quotient.
1182
+ */
1183
+ public function testQuotient(string $dividend, string $divisor, string $quotient) : void
1184
+ {
1185
+ self::assertBigIntegerEquals($quotient, BigInteger::of($dividend)->quotient($divisor));
1186
+ }
1187
+
1188
+ public function testQuotientOfZeroThrowsException() : void
1189
+ {
1190
+ $this->expectException(DivisionByZeroException::class);
1191
+ BigInteger::of(1)->quotient(0);
1192
+ }
1193
+
1194
+ /**
1195
+ * @dataProvider providerQuotientAndRemainder
1196
+ *
1197
+ * @param string $dividend The dividend.
1198
+ * @param string $divisor The divisor.
1199
+ * @param string $quotient The expected quotient (ignored for this test).
1200
+ * @param string $remainder The expected remainder.
1201
+ */
1202
+ public function testRemainder(string $dividend, string $divisor, string $quotient, string $remainder) : void
1203
+ {
1204
+ self::assertBigIntegerEquals($remainder, BigInteger::of($dividend)->remainder($divisor));
1205
+ }
1206
+
1207
+ public function testRemainderOfZeroThrowsException() : void
1208
+ {
1209
+ $this->expectException(DivisionByZeroException::class);
1210
+ BigInteger::of(1)->remainder(0);
1211
+ }
1212
+
1213
+ /**
1214
+ * @dataProvider providerQuotientAndRemainder
1215
+ *
1216
+ * @param string $dividend The dividend.
1217
+ * @param string $divisor The divisor.
1218
+ * @param string $quotient The expected quotient.
1219
+ * @param string $remainder The expected remainder.
1220
+ */
1221
+ public function testQuotientAndRemainder(string $dividend, string $divisor, string $quotient, string $remainder) : void
1222
+ {
1223
+ [$q, $r] = BigInteger::of($dividend)->quotientAndRemainder($divisor);
1224
+
1225
+ self::assertBigIntegerEquals($quotient, $q);
1226
+ self::assertBigIntegerEquals($remainder, $r);
1227
+ }
1228
+
1229
+ public function providerQuotientAndRemainder() : array
1230
+ {
1231
+ return [
1232
+ ['1', '123', '0', '1'],
1233
+ ['1', '-123', '0', '1'],
1234
+ ['-1', '123', '0', '-1'],
1235
+ ['-1', '-123', '0', '-1'],
1236
+
1237
+ ['-21', '4', '-5', '-1'],
1238
+
1239
+ ['1999999999999999999999999', '2000000000000000000000000', '0', '1999999999999999999999999'],
1240
+ ['1999999999999999999999999', '-2000000000000000000000000', '0', '1999999999999999999999999'],
1241
+ ['-1999999999999999999999999', '2000000000000000000000000', '0', '-1999999999999999999999999'],
1242
+ ['-1999999999999999999999999', '-2000000000000000000000000', '0', '-1999999999999999999999999'],
1243
+
1244
+ ['123', '1', '123', '0'],
1245
+ ['123', '-1', '-123', '0'],
1246
+ ['-123', '1', '-123', '0'],
1247
+ ['-123', '-1', '123', '0'],
1248
+
1249
+ ['123', '2', '61', '1'],
1250
+ ['123', '-2', '-61', '1'],
1251
+ ['-123', '2', '-61', '-1'],
1252
+ ['-123', '-2', '61', '-1'],
1253
+
1254
+ ['123', '123', '1', '0'],
1255
+ ['123', '-123', '-1', '0'],
1256
+ ['-123', '123', '-1', '0'],
1257
+ ['-123', '-123', '1', '0'],
1258
+
1259
+ ['123', '124', '0', '123'],
1260
+ ['123', '-124', '0', '123'],
1261
+ ['-123', '124', '0', '-123'],
1262
+ ['-123', '-124', '0', '-123'],
1263
+
1264
+ ['124', '123', '1', '1'],
1265
+ ['124', '-123', '-1', '1'],
1266
+ ['-124', '123', '-1', '-1'],
1267
+ ['-124', '-123', '1', '-1'],
1268
+
1269
+ ['1000000000000000000000000000000', '3', '333333333333333333333333333333', '1'],
1270
+ ['1000000000000000000000000000000', '9', '111111111111111111111111111111', '1'],
1271
+ ['1000000000000000000000000000000', '11', '90909090909090909090909090909', '1'],
1272
+ ['1000000000000000000000000000000', '13', '76923076923076923076923076923', '1'],
1273
+ ['1000000000000000000000000000000', '21', '47619047619047619047619047619', '1'],
1274
+
1275
+ ['123456789123456789123456789', '987654321987654321', '124999998', '850308642973765431'],
1276
+ ['123456789123456789123456789', '-87654321987654321', '-1408450676', '65623397056685793'],
1277
+ ['-123456789123456789123456789', '7654321987654321', '-16129030020', '-1834176331740369'],
1278
+ ['-123456789123456789123456789', '-654321987654321', '188678955396', '-205094497790673'],
1279
+
1280
+ ['123456789098765432101234567890987654321', '1', '123456789098765432101234567890987654321', '0'],
1281
+ ['123456789098765432101234567890987654321', '-1', '-123456789098765432101234567890987654321', '0'],
1282
+ ['1282493059039502950823948435791053205342314', '24342491090593053', '52685366270303839158198740', '4167539367989094'],
1283
+ ['1000000000000000000000000000000000000000000000', '7777777777777777', '128571428571428584285714285714', '2232222222222222'],
1284
+ ['999999999999999999999999999999999999999999999', '22221222222', '45002025091579141312274843781092897', '13737242865'],
1285
+ ['49283205308081983923480483094304390249024223', '-23981985358744892239240813', '-2055009398548863185', '20719258837232321643854818'],
1286
+ ['-8378278174814983902084304176539029302438924', '384758527893793829309012129991', '-21775419041855', '-367584271343844173835372665619'],
1287
+ ['-444444444444444444444444444444444444411111', '-33333333333333', '13333333333333466666666666667', '-33333333300000'],
1288
+ ];
1289
+ }
1290
+
1291
+ public function testQuotientAndRemainderByZeroThrowsException() : void
1292
+ {
1293
+ $this->expectException(DivisionByZeroException::class);
1294
+ BigInteger::of(1)->quotientAndRemainder(0);
1295
+ }
1296
+
1297
+ /**
1298
+ * @dataProvider providerMod
1299
+ */
1300
+ public function testMod(string $dividend, string $divisor, string $expected) : void
1301
+ {
1302
+ self::assertBigIntegerEquals($expected, BigInteger::of($dividend)->mod($divisor));
1303
+ }
1304
+
1305
+ public function providerMod() : array
1306
+ {
1307
+ return [
1308
+ ['0', '1', '0'],
1309
+ ['0', '-1', '0'],
1310
+
1311
+ ['1', '123', '1'],
1312
+ ['1', '-123', '-122'],
1313
+ ['-1', '123', '122'],
1314
+ ['-1', '-123', '-1'],
1315
+
1316
+ ['2', '7', '2'],
1317
+ ['2', '-7', '-5'],
1318
+ ['-2', '7', '5'],
1319
+ ['-2', '-7', '-2'],
1320
+
1321
+ ['12', '7', '5'],
1322
+ ['12', '-7', '-2'],
1323
+ ['-12', '7', '2'],
1324
+ ['-12', '-7', '-5'],
1325
+
1326
+ ['123', '1', '0'],
1327
+ ['123', '-1', '0'],
1328
+ ['-123', '1', '0'],
1329
+ ['-123', '-1', '0'],
1330
+
1331
+ ['123', '2', '1'],
1332
+ ['123', '-2', '-1'],
1333
+ ['-123', '2', '1'],
1334
+ ['-123', '-2', '-1'],
1335
+
1336
+ ['123', '123', '0'],
1337
+ ['123', '-123', '0'],
1338
+ ['-123', '123', '0'],
1339
+ ['-123', '-123', '0'],
1340
+
1341
+ ['123', '124', '123'],
1342
+ ['123', '-124', '-1'],
1343
+ ['-123', '124', '1'],
1344
+ ['-123', '-124', '-123'],
1345
+
1346
+ ['124', '123', '1'],
1347
+ ['124', '-123', '-122'],
1348
+ ['-124', '123', '122'],
1349
+ ['-124', '-123', '-1'],
1350
+
1351
+ ['100000000', '353467', '322306'],
1352
+ ['100000000', '-353467', '-31161'],
1353
+ ['-100000000', '353467', '31161'],
1354
+ ['-100000000', '-353467', '-322306'],
1355
+
1356
+ ['1999999999999999999999999', '2000000000000000000000000', '1999999999999999999999999'],
1357
+ ['1999999999999999999999999', '-2000000000000000000000000', '-1'],
1358
+ ['-1999999999999999999999999', '2000000000000000000000000', '1'],
1359
+ ['-1999999999999999999999999', '-2000000000000000000000000', '-1999999999999999999999999'],
1360
+
1361
+ ['1000000000000000000000000000000', '3', '1'],
1362
+ ['1000000000000000000000000000000', '-3', '-2'],
1363
+ ['1000000000000000000000000000000', '9', '1'],
1364
+ ['1000000000000000000000000000000', '-9', '-8'],
1365
+ ['1000000000000000000000000000000', '11', '1'],
1366
+ ['1000000000000000000000000000000', '-11', '-10'],
1367
+ ['1000000000000000000000000000000', '13', '1'],
1368
+ ['1000000000000000000000000000000', '-13', '-12'],
1369
+ ['1000000000000000000000000000000', '21', '1'],
1370
+ ['1000000000000000000000000000000', '-21', '-20'],
1371
+
1372
+ ['123456789123456789123456789', '987654321987654321', '850308642973765431'],
1373
+ ['123456789123456789123456789', '-87654321987654321', '-22030924930968528'],
1374
+ ['-123456789123456789123456789', '7654321987654321', '5820145655913952'],
1375
+ ['-123456789123456789123456789', '-654321987654321', '-205094497790673'],
1376
+
1377
+ ['123456789098765432101234567890987654321', '1', '0'],
1378
+ ['123456789098765432101234567890987654321', '-1', '0'],
1379
+ ['1282493059039502950823948435791053205342314', '24342491090593053', '4167539367989094'],
1380
+ ['1000000000000000000000000000000000000000000000', '7777777777777777', '2232222222222222'],
1381
+ ['999999999999999999999999999999999999999999999', '22221222222', '13737242865'],
1382
+ ['49283205308081983923480483094304390249024223', '-23981985358744892239240813', '-3262726521512570595385995'],
1383
+ ['-8378278174814983902084304176539029302438924', '384758527893793829309012129991', '17174256549949655473639464372'],
1384
+ ['-444444444444444444444444444444444444411111', '-33333333333333', '-33333333300000'],
1385
+ ];
1386
+ }
1387
+
1388
+ public function testModZeroThrowsException() : void
1389
+ {
1390
+ $this->expectException(DivisionByZeroException::class);
1391
+ BigInteger::of(1)->mod(0);
1392
+ }
1393
+
1394
+ /**
1395
+ * @dataProvider providerModPow
1396
+ */
1397
+ public function testModPow(string $base, string $exp, string $mod, string $expected) : void
1398
+ {
1399
+ self::assertBigIntegerEquals($expected, BigInteger::of($base)->modPow($exp, $mod));
1400
+ }
1401
+
1402
+ public function providerModPow() : array
1403
+ {
1404
+ return [
1405
+ ['0', '0', '1', '0'],
1406
+ ['0', '1', '1', '0'],
1407
+ ['1', '0', '1', '0'],
1408
+ ['1', '1', '1', '0'],
1409
+ ['0', '1', '10', '0'],
1410
+ ['5', '1', '10', '5'],
1411
+ ['77', '3', '1000', '533'],
1412
+ ['11', '3', '1000', '331'],
1413
+ ['11', '7', '1000', '171'],
1414
+ ['11', '7', '900', '371'],
1415
+ ['2988348162058574136915891421498819466320163312926952423791023078876139', '2351399303373464486466122544523690094744975233415544072992656881240319', '10000000000000000000000000000000000000000', '1527229998585248450016808958343740453059']
1416
+ ];
1417
+ }
1418
+
1419
+ /**
1420
+ * Crypto test from phpseclib test suite.
1421
+ */
1422
+ public function testModPowCrypto() : void
1423
+ {
1424
+ if (Calculator::get() instanceof Calculator\NativeCalculator) {
1425
+ if (getenv('CI') === 'true') {
1426
+ $this->markTestSkipped('This test is currently too slow for the CI.');
1427
+ }
1428
+ }
1429
+
1430
+ $prime = BigInteger::fromBase(
1431
+ 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1' .
1432
+ '29024E088A67CC74020BBEA63B139B22514A08798E3404DD' .
1433
+ 'EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245' .
1434
+ 'E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
1435
+ 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D' .
1436
+ 'C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F' .
1437
+ '83655D23DCA3AD961C62F356208552BB9ED529077096966D' .
1438
+ '670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' .
1439
+ 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9' .
1440
+ 'DE2BCBF6955817183995497CEA956AE515D2261898FA0510' .
1441
+ '15728E5A8AACAA68FFFFFFFFFFFFFFFF',
1442
+ 16
1443
+ );
1444
+
1445
+ $generator = BigInteger::of(2);
1446
+
1447
+ $alicePrivate = BigInteger::fromBase(
1448
+ '22606EDA7960458BC9D65F46DD96F114F9A004F0493C1F26' .
1449
+ '2139D2C8063B733162E876182CA3BF063AB1A167ABDB7F03' .
1450
+ 'E0A225A6205660439F6CE46D252069FF',
1451
+ 16
1452
+ );
1453
+
1454
+ $bobPrivate = BigInteger::fromBase(
1455
+ '6E3EFA13A96025D63E4B0D88A09B3A46DDFE9DD3BC9D1655' .
1456
+ '4898C02B4AC181F0CEB4E818664B12F02C71A07215C400F9' .
1457
+ '88352A4779F3E88836F7C3D3B3C739DE',
1458
+ 16
1459
+ );
1460
+
1461
+ $alicePublic = $generator->modPow($alicePrivate, $prime);
1462
+ $bobPublic = $generator->modPow($bobPrivate, $prime);
1463
+
1464
+ $aliceShared = $bobPublic->modPow($alicePrivate, $prime);
1465
+ $bobShared = $alicePublic->modPow($bobPrivate, $prime);
1466
+
1467
+ self::assertTrue($aliceShared->isEqualTo($bobShared));
1468
+ }
1469
+
1470
+ /**
1471
+ * @dataProvider providerModPowNegativeThrowsException
1472
+ */
1473
+ public function testModPowNegativeThrowsException(int $base, int $exp, int $mod) : void
1474
+ {
1475
+ $this->expectException(NegativeNumberException::class);
1476
+ BigInteger::of($base)->modPow($exp, $mod);
1477
+ }
1478
+
1479
+ public function providerModPowNegativeThrowsException() : array
1480
+ {
1481
+ return [
1482
+ [ 1, 1, -1],
1483
+ [ 1, -1, 1],
1484
+ [-1, 1, 1],
1485
+ ];
1486
+ }
1487
+
1488
+ public function testModPowZeroThrowsException() : void
1489
+ {
1490
+ $this->expectException(DivisionByZeroException::class);
1491
+ BigInteger::of(1)->modPow(1, 0);
1492
+ }
1493
+
1494
+ /**
1495
+ * @dataProvider providerPower
1496
+ *
1497
+ * @param string $number The base number.
1498
+ * @param int $exponent The exponent to apply.
1499
+ * @param string $expected The expected result.
1500
+ */
1501
+ public function testPower(string $number, int $exponent, string $expected) : void
1502
+ {
1503
+ self::assertBigIntegerEquals($expected, BigInteger::of($number)->power($exponent));
1504
+ }
1505
+
1506
+ public function providerPower() : array
1507
+ {
1508
+ return [
1509
+ ['-3', 0, '1'],
1510
+ ['-2', 0, '1'],
1511
+ ['-1', 0, '1'],
1512
+ ['0', 0, '1'],
1513
+ ['1', 0, '1'],
1514
+ ['2', 0, '1'],
1515
+ ['3', 0, '1'],
1516
+
1517
+ ['-3', 1, '-3'],
1518
+ ['-2', 1, '-2'],
1519
+ ['-1', 1, '-1'],
1520
+ ['0', 1, '0'],
1521
+ ['1', 1, '1'],
1522
+ ['2', 1, '2'],
1523
+ ['3', 1, '3'],
1524
+
1525
+ ['-3', 2, '9'],
1526
+ ['-2', 2, '4'],
1527
+ ['-1', 2, '1'],
1528
+ ['0', 2, '0'],
1529
+ ['1', 2, '1'],
1530
+ ['2', 2, '4'],
1531
+ ['3', 2, '9'],
1532
+
1533
+ ['-3', 3, '-27'],
1534
+ ['-2', 3, '-8'],
1535
+ ['-1', 3, '-1'],
1536
+ ['0', 3, '0'],
1537
+ ['1', 3, '1'],
1538
+ ['2', 3, '8'],
1539
+ ['3', 3, '27'],
1540
+
1541
+ ['0', 1000000, '0'],
1542
+ ['1', 1000000, '1'],
1543
+
1544
+ ['-2', 255, '-57896044618658097711785492504343953926634992332820282019728792003956564819968'],
1545
+ [ '2', 256, '115792089237316195423570985008687907853269984665640564039457584007913129639936'],
1546
+
1547
+ ['-123', 33, '-926549609804623448265268294182900512918058893428212027689876489708283'],
1548
+ [ '123', 34, '113965602005968684136628000184496763088921243891670079405854808234118809'],
1549
+
1550
+ ['-123456789', 8, '53965948844821664748141453212125737955899777414752273389058576481'],
1551
+ ['9876543210', 7, '9167159269868350921847491739460569765344716959834325922131706410000000']
1552
+ ];
1553
+ }
1554
+
1555
+ /**
1556
+ * @dataProvider providerPowerWithInvalidExponentThrowsException
1557
+ */
1558
+ public function testPowerWithInvalidExponentThrowsException(int $power) : void
1559
+ {
1560
+ $this->expectException(\InvalidArgumentException::class);
1561
+ BigInteger::of(1)->power($power);
1562
+ }
1563
+
1564
+ public function providerPowerWithInvalidExponentThrowsException() : array
1565
+ {
1566
+ return [
1567
+ [-1],
1568
+ [1000001]
1569
+ ];
1570
+ }
1571
+
1572
+ /**
1573
+ * @dataProvider providerGcd
1574
+ *
1575
+ * @param string $a The first number.
1576
+ * @param string $b The second number.
1577
+ * @param string $gcd The expected GCD.
1578
+ */
1579
+ public function testGcd(string $a, string $b, string $gcd) : void
1580
+ {
1581
+ $a = BigInteger::of($a);
1582
+ $b = BigInteger::of($b);
1583
+
1584
+ self::assertBigIntegerEquals($gcd, $a->gcd($b));
1585
+ }
1586
+
1587
+ public function providerGcd() : \Generator
1588
+ {
1589
+ $tests = [
1590
+ ['0', '0', '0'],
1591
+
1592
+ ['123456789123456789123456789123456789', '0', '123456789123456789123456789123456789'],
1593
+ ['123456789123456789123456789123456789', '1', '1'],
1594
+ ['123456789123456789123456789123456789', '2', '1'],
1595
+ ['123456789123456789123456789123456789', '3', '3'],
1596
+ ['123456789123456789123456789123456789', '4', '1'],
1597
+ ['123456789123456789123456789123456789', '5', '1'],
1598
+ ['123456789123456789123456789123456789', '6', '3'],
1599
+ ['123456789123456789123456789123456789', '7', '7'],
1600
+ ['123456789123456789123456789123456789', '8', '1'],
1601
+ ['123456789123456789123456789123456789', '9', '9'],
1602
+ ['123456789123456789123456789123456789', '10', '1'],
1603
+ ['123456789123456789123456789123456789', '11', '11'],
1604
+ ['123456789123456789123456789123456789', '12', '3'],
1605
+ ['123456789123456789123456789123456789', '13', '13'],
1606
+ ['123456789123456789123456789123456789', '14', '7'],
1607
+ ['123456789123456789123456789123456789', '15', '3'],
1608
+ ['123456789123456789123456789123456789', '16', '1'],
1609
+ ['123456789123456789123456789123456789', '17', '1'],
1610
+ ['123456789123456789123456789123456789', '18', '9'],
1611
+ ['123456789123456789123456789123456789', '19', '19'],
1612
+ ['123456789123456789123456789123456789', '20', '1'],
1613
+ ['123456789123456789123456789123456789', '100', '1'],
1614
+ ['123456789123456789123456789123456789', '101', '101'],
1615
+ ['123456789123456789123456789123456789', '102', '3'],
1616
+ ['123456789123456789123456789123456789', '103', '1'],
1617
+ ['123456789123456789123456789123456789', '104', '13'],
1618
+ ['123456789123456789123456789123456789', '105', '21'],
1619
+ ['123456789123456789123456789123456789', '985', '1'],
1620
+ ['123456789123456789123456789123456789', '986', '1'],
1621
+ ['123456789123456789123456789123456789', '987', '21'],
1622
+ ['123456789123456789123456789123456789', '988', '247'],
1623
+ ['123456789123456789123456789123456789', '989', '1'],
1624
+ ['123456789123456789123456789123456789', '990', '99'],
1625
+ ['123456789123456789123456789123456789', '10010', '1001'],
1626
+ ['123456789123456789123456789123456789', '10017', '63'],
1627
+ ['123456789123456789123456789123456789', '10089', '171'],
1628
+ ['123456789123456789123456789123456789', '10098', '99'],
1629
+ ['123456789123456789123456789123456789', '100035', '2223'],
1630
+ ['123456789123456789123456789123456789', '1000065', '627'],
1631
+ ['123456789123456789123456789123456789', '10000068', '39'],
1632
+ ['123456789123456789123456789123456789', '10001222', '7777'],
1633
+ ['123456789123456789123456789123456789', '10001277', '24453'],
1634
+ ['123456789123456789123456789123456789', '100005258', '157737'],
1635
+ ['123456789123456789123456789123456789', '100010001', '2702973'],
1636
+ ['123456789123456789123456789123456789', '100148202', '50074101'],
1637
+ ['123456789123456789123456789123456789', '100478469', '14354067'],
1638
+ ['123456789123456789123456789123456789', '123456789140121129', '8249681517'],
1639
+ ['123456789123456789123456789123456789', '123456789150891631', '1385459521'],
1640
+ ['123456789123456789123456789123456789', '123456789192058322', '6928754833'],
1641
+ ['123456789123456789123456789123456789', '123456789202361433', '1992342261'],
1642
+ ['123456789123456789123456789123456789', '999456789162772941', '20786264499'],
1643
+ ['123456789123456789123456789123456789', '999456789176548074', '2345678991'],
1644
+ ['123456789123456789123456789123456789', '999456789188938248', '2372170689'],
1645
+
1646
+ ['88888777776666655555444443333322222111110000099999', '100000000011886128', '8252579097'],
1647
+ ['88888777776666655555444443333322222111110000099999', '100000000013330403', '1162443303'],
1648
+ ['88888777776666655555444443333322222111110000099999', '100000000020221920', '2470053077'],
1649
+ ['88888777776666655555444443333322222111110000099999', '100000000031937250', '3970893353'],
1650
+ ['88888777776666655555444443333322222111110000099999', '100000000043341848', '1102420413'],
1651
+ ['88888777776666655555444443333322222111110000099999', '100000000047565681', '1212240071'],
1652
+ ['88888777776666655555444443333322222111110000099999', '100000000065586124', '1172302873'],
1653
+ ['88888777776666655555444443333322222111110000099999', '100000000068684846', '1051734417'],
1654
+ ['88888777776666655555444443333322222111110000099999', '100000000068736887', '2423071539'],
1655
+ ];
1656
+
1657
+ foreach ($tests as [$a, $b, $gcd]) {
1658
+ yield [$a, $b, $gcd];
1659
+ yield [$b, $a, $gcd];
1660
+
1661
+ yield [$a, "-$b", $gcd];
1662
+ yield [$b, "-$a", $gcd];
1663
+
1664
+ yield ["-$a", $b, $gcd];
1665
+ yield ["-$b", $a, $gcd];
1666
+
1667
+ yield ["-$a", "-$b", $gcd];
1668
+ yield ["-$b", "-$a", $gcd];
1669
+ }
1670
+ }
1671
+
1672
+ /**
1673
+ * @dataProvider providerSqrt
1674
+ */
1675
+ public function testSqrt(string $number, string $sqrt) : void
1676
+ {
1677
+ $number = BigInteger::of($number);
1678
+
1679
+ self::assertBigIntegerEquals($sqrt, $number->sqrt());
1680
+ }
1681
+
1682
+ public function providerSqrt() : array
1683
+ {
1684
+ return [
1685
+ ['0', '0'],
1686
+ ['1', '1'],
1687
+ ['3', '1'],
1688
+ ['4', '2'],
1689
+ ['8', '2'],
1690
+ ['9', '3'],
1691
+ ['15', '3'],
1692
+ ['16', '4'],
1693
+ ['24', '4'],
1694
+ ['25', '5'],
1695
+ ['35', '5'],
1696
+ ['36', '6'],
1697
+ ['48', '6'],
1698
+ ['49', '7'],
1699
+ ['63', '7'],
1700
+ ['64', '8'],
1701
+ ['80', '8'],
1702
+ ['81', '9'],
1703
+ ['99', '9'],
1704
+ ['100', '10'],
1705
+
1706
+ ['536137214136734800142146901786039940282473271927911507640625', '732213912826528310663262741625'],
1707
+ ['536137214136734800142146901787504368108126328549238033123875', '732213912826528310663262741625'],
1708
+ ['536137214136734800142146901787504368108126328549238033123876', '732213912826528310663262741626'],
1709
+ ['5651495859544574019979802175954184725583245698990648064256', '75176431543034642899535752016'],
1710
+ ['5651495859544574019979802176104537588669314984789719568288', '75176431543034642899535752016'],
1711
+ ['5651495859544574019979802176104537588669314984789719568289', '75176431543034642899535752017'],
1712
+ ['303791344535904055863813752643405021077478121784571407761729', '551172699374618931119694672223'],
1713
+ ['303791344535904055863813752644507366476227359646810797106175', '551172699374618931119694672223'],
1714
+ ['303791344535904055863813752644507366476227359646810797106176', '551172699374618931119694672224'],
1715
+ ['563247882222081148212230590155705163466381822617812257437849', '750498422531374244468346132293'],
1716
+ ['563247882222081148212230590157206160311444571106748949702435', '750498422531374244468346132293'],
1717
+ ['563247882222081148212230590157206160311444571106748949702436', '750498422531374244468346132294'],
1718
+ ['396189426113498637323382117462633843296333578307938768136329', '629435799834660371475569807677'],
1719
+ ['396189426113498637323382117463892714896002899050889907751683', '629435799834660371475569807677'],
1720
+ ['396189426113498637323382117463892714896002899050889907751684', '629435799834660371475569807678'],
1721
+ ['80479328054895287914569547663334257436697869675619064535360356', '8971027146034911420307518533066'],
1722
+ ['80479328054895287914569547663352199490989939498459679572426488', '8971027146034911420307518533066'],
1723
+ ['80479328054895287914569547663352199490989939498459679572426489', '8971027146034911420307518533067'],
1724
+ ['681849477075053403257629437089098232501847587591122144140625', '825741773846432819101899135625'],
1725
+ ['681849477075053403257629437090749716049540453229325942411875', '825741773846432819101899135625'],
1726
+ ['681849477075053403257629437090749716049540453229325942411876', '825741773846432819101899135626'],
1727
+ ['74137461815059419705618984794190691016668430175974095624129600', '8610311365743948501801103299640'],
1728
+ ['74137461815059419705618984794207911639399918072977697830728880', '8610311365743948501801103299640'],
1729
+ ['74137461815059419705618984794207911639399918072977697830728881', '8610311365743948501801103299641'],
1730
+ ['6679657010858483937903991845397665010485952775098785560735409', '2584503242570704134867997320903'],
1731
+ ['6679657010858483937903991845402834016971094183368521555377215', '2584503242570704134867997320903'],
1732
+ ['6679657010858483937903991845402834016971094183368521555377216', '2584503242570704134867997320904'],
1733
+ ['76167329888878964758237229146072291137608533898056659182403025', '8727389637736988579847341871305'],
1734
+ ['76167329888878964758237229146089745916884007875216353866145635', '8727389637736988579847341871305'],
1735
+ ['76167329888878964758237229146089745916884007875216353866145636', '8727389637736988579847341871306'],
1736
+ ['6743391560146249598812429163892766868360953827745248726306064', '2596804105077287033903247753508'],
1737
+ ['6743391560146249598812429163897960476571108401813055221813080', '2596804105077287033903247753508'],
1738
+ ['6743391560146249598812429163897960476571108401813055221813081', '2596804105077287033903247753509'],
1739
+ ['1867791142724588955955814039055642821336323719154250751224723556', '43217949311884164825638553209334'],
1740
+ ['1867791142724588955955814039055729257234947487483902028331142224', '43217949311884164825638553209334'],
1741
+ ['1867791142724588955955814039055729257234947487483902028331142225', '43217949311884164825638553209335'],
1742
+ ['9830504148113505106730565430925806810010750548232214925001449636', '99148898874942151859351963400806'],
1743
+ ['9830504148113505106730565430926005107808500432535933628928251248', '99148898874942151859351963400806'],
1744
+ ['9830504148113505106730565430926005107808500432535933628928251249', '99148898874942151859351963400807'],
1745
+ ['7591171119877361934423335814652578116545218322867005352922382400', '87127327055737007353139169677320'],
1746
+ ['7591171119877361934423335814652752371199329796881711631261737040', '87127327055737007353139169677320'],
1747
+ ['7591171119877361934423335814652752371199329796881711631261737041', '87127327055737007353139169677321'],
1748
+ ['8534704621867005063010169093165229825021562891964253458234113600', '92383465089089427718873950884440'],
1749
+ ['8534704621867005063010169093165414591951741070819691206135882480', '92383465089089427718873950884440'],
1750
+ ['8534704621867005063010169093165414591951741070819691206135882481', '92383465089089427718873950884441'],
1751
+ ['558060557515620507133380963948250962461823927030515012873505842176', '747034508918845399769072043504224'],
1752
+ ['558060557515620507133380963948252456530841764721314551017592850624', '747034508918845399769072043504224'],
1753
+ ['558060557515620507133380963948252456530841764721314551017592850625', '747034508918845399769072043504225'],
1754
+ ['200538408436782201630574692476963942210287537291410052113367162944', '447815149851791192871220236705288'],
1755
+ ['200538408436782201630574692476964837840587240873795794553840573520', '447815149851791192871220236705288'],
1756
+ ['200538408436782201630574692476964837840587240873795794553840573521', '447815149851791192871220236705289'],
1757
+ ['191302866278956628715433979906440851661028066577090295375612311364', '437381831217251900054617942999442'],
1758
+ ['191302866278956628715433979906441726424690501080890404611498310248', '437381831217251900054617942999442'],
1759
+ ['191302866278956628715433979906441726424690501080890404611498310249', '437381831217251900054617942999443'],
1760
+ ['291290137244253022092289121327605756463305738312066948462328733721', '539713013780706442298424414941189'],
1761
+ ['291290137244253022092289121327606835889333299724951545311158616099', '539713013780706442298424414941189'],
1762
+ ['291290137244253022092289121327606835889333299724951545311158616100', '539713013780706442298424414941190'],
1763
+ ['5025051069729848944739380852251409470255071569439258719898537481', '70887594610974415152598103986941'],
1764
+ ['5025051069729848944739380852251551245444293518269563916106511363', '70887594610974415152598103986941'],
1765
+ ['5025051069729848944739380852251551245444293518269563916106511364', '70887594610974415152598103986942'],
1766
+ ['6238861109923404442965423418956764090860907116154205636120522931561', '2497771228500201225537381791181331'],
1767
+ ['6238861109923404442965423418956769086403364116556656710884105294223', '2497771228500201225537381791181331'],
1768
+ ['6238861109923404442965423418956769086403364116556656710884105294224', '2497771228500201225537381791181332'],
1769
+ ['20023427755036504641354330839858631034820554187187074374005311969476', '4474754491034843873667293532006926'],
1770
+ ['20023427755036504641354330839858639984329536256874821708592375983328', '4474754491034843873667293532006926'],
1771
+ ['20023427755036504641354330839858639984329536256874821708592375983329', '4474754491034843873667293532006927'],
1772
+ ['35963041045659882033621773487569203358608603414532908772894092442881', '5996919296243687322881924437376641'],
1773
+ ['35963041045659882033621773487569215352447195901907554536742967196163', '5996919296243687322881924437376641'],
1774
+ ['35963041045659882033621773487569215352447195901907554536742967196164', '5996919296243687322881924437376642'],
1775
+ ['16147491963439711944418728362110466093273207282720057861529178507569', '4018394202096119880426988697249913'],
1776
+ ['16147491963439711944418728362110474130061611474959818715506573007395', '4018394202096119880426988697249913'],
1777
+ ['16147491963439711944418728362110474130061611474959818715506573007396', '4018394202096119880426988697249914'],
1778
+ ['59275127168144151414318593405790938619095816316145068714478973756416', '7699034171124593171733765899358304'],
1779
+ ['59275127168144151414318593405790954017164158565331412182010772473024', '7699034171124593171733765899358304'],
1780
+ ['59275127168144151414318593405790954017164158565331412182010772473025', '7699034171124593171733765899358305'],
1781
+ ['5285010890475466266241012129886993921224228841648175760159220822102500', '72698080376826087595732320834198550'],
1782
+ ['5285010890475466266241012129886994066620389595300350951623862490499600', '72698080376826087595732320834198550'],
1783
+ ['5285010890475466266241012129886994066620389595300350951623862490499601', '72698080376826087595732320834198551'],
1784
+ ['138806460367120633162909304707973463857407594119348580175849319475249', '11781615354743195534745216445516807'],
1785
+ ['138806460367120633162909304707973487420638303605739649666282210508863', '11781615354743195534745216445516807'],
1786
+ ['138806460367120633162909304707973487420638303605739649666282210508864', '11781615354743195534745216445516808'],
1787
+ ['4394593323188981215423145755036811566487951532301290484907917429040356', '66291728919896041699308382947726934'],
1788
+ ['4394593323188981215423145755036811699071409372093373883524683324494224', '66291728919896041699308382947726934'],
1789
+ ['4394593323188981215423145755036811699071409372093373883524683324494225', '66291728919896041699308382947726935'],
1790
+ ['2165102898894822021490897916929619474531175829310332070795169853731396', '46530666220190980857729715988167086'],
1791
+ ['2165102898894822021490897916929619567592508269692293786254601830065568', '46530666220190980857729715988167086'],
1792
+ ['2165102898894822021490897916929619567592508269692293786254601830065569', '46530666220190980857729715988167087'],
1793
+ ['3387136764299263076201461182231668509909087521737501460409373154998724', '58199113088596660127381090812371918'],
1794
+ ['3387136764299263076201461182231668626307313698930821715171554779742560', '58199113088596660127381090812371918'],
1795
+ ['3387136764299263076201461182231668626307313698930821715171554779742561', '58199113088596660127381090812371919'],
1796
+ ['598571098379632349988804996185789284322923089459844190238738309900665041', '773673767410807557353849214204230071'],
1797
+ ['598571098379632349988804996185789285870270624281459304946436738309125183', '773673767410807557353849214204230071'],
1798
+ ['598571098379632349988804996185789285870270624281459304946436738309125184', '773673767410807557353849214204230072'],
1799
+ ['520654040364073618548858305514718008281370888178241149423087536697602769', '721563607982050061031165602524215113'],
1800
+ ['520654040364073618548858305514718009724498104142341271485418741746032995', '721563607982050061031165602524215113'],
1801
+ ['520654040364073618548858305514718009724498104142341271485418741746032996', '721563607982050061031165602524215114'],
1802
+ ['49468236740249321869413367805106481368010073927095236023233757323825636', '222414560540107899360763128216988694'],
1803
+ ['49468236740249321869413367805106481812839195007311034744760013757803024', '222414560540107899360763128216988694'],
1804
+ ['49468236740249321869413367805106481812839195007311034744760013757803025', '222414560540107899360763128216988695'],
1805
+ ['752985146631183783668626620327136132189678265369154785125113211857131025', '867747167457885617308484616342840855'],
1806
+ ['752985146631183783668626620327136133925172600284926019742082444542812735', '867747167457885617308484616342840855'],
1807
+ ['752985146631183783668626620327136133925172600284926019742082444542812736', '867747167457885617308484616342840856'],
1808
+ ['4964939306071472434861762119449573856931127119323966160723135793312400', '70462325437580276008386497095248180'],
1809
+ ['4964939306071472434861762119449573997855777994484518177496129983808760', '70462325437580276008386497095248180'],
1810
+ ['4964939306071472434861762119449573997855777994484518177496129983808761', '70462325437580276008386497095248181'],
1811
+ ['6793060375719308872947059218122494900670395578602098991588961245675868921', '2606350010209547598885835947629243339'],
1812
+ ['6793060375719308872947059218122494905883095599021194189360633140934355599', '2606350010209547598885835947629243339'],
1813
+ ['6793060375719308872947059218122494905883095599021194189360633140934355600', '2606350010209547598885835947629243340'],
1814
+ ['72434023187588979108181351955877408189952248642066292273939239044048882404', '8510818009309620944867597322534681898'],
1815
+ ['72434023187588979108181351955877408206973884660685534163674433689118246200', '8510818009309620944867597322534681898'],
1816
+ ['72434023187588979108181351955877408206973884660685534163674433689118246201', '8510818009309620944867597322534681899'],
1817
+ ['11820228792957342809567646506028581034714829445539021053517615632467438404', '3438055961289365459878259691983242898'],
1818
+ ['11820228792957342809567646506028581041590941368117751973274135016433924200', '3438055961289365459878259691983242898'],
1819
+ ['11820228792957342809567646506028581041590941368117751973274135016433924201', '3438055961289365459878259691983242899'],
1820
+ ['6386392982997549868964551665256601064299977946311952729197080155224215225', '2527131374305172498893486771925871765'],
1821
+ ['6386392982997549868964551665256601069354240694922297726984053699075958755', '2527131374305172498893486771925871765'],
1822
+ ['6386392982997549868964551665256601069354240694922297726984053699075958756', '2527131374305172498893486771925871766'],
1823
+ ['241100595746204845568053694673173646954637963055159189070656778312291856', '491019954529553559943132903540543684'],
1824
+ ['241100595746204845568053694673173647936677872114266308956922585393379224', '491019954529553559943132903540543684'],
1825
+ ['241100595746204845568053694673173647936677872114266308956922585393379225', '491019954529553559943132903540543685'],
1826
+ ['9443978332159357501114101827797274207266380117275222876917889364528773973136', '97180133423243238008221615153136002444'],
1827
+ ['9443978332159357501114101827797274207460740384121709352934332594835045978024', '97180133423243238008221615153136002444'],
1828
+ ['9443978332159357501114101827797274207460740384121709352934332594835045978025', '97180133423243238008221615153136002445'],
1829
+ ['313018699256618409001992020847417266900442089718999098874457999889859130596', '17692334477298873658720698607769718186'],
1830
+ ['313018699256618409001992020847417266935826758673596846191899397105398566968', '17692334477298873658720698607769718186'],
1831
+ ['313018699256618409001992020847417266935826758673596846191899397105398566969', '17692334477298873658720698607769718187'],
1832
+ ['6933071107478585245042253386666659991142755133413332931821052899578751610000', '83265065348431602879537003312633461900'],
1833
+ ['6933071107478585245042253386666659991309285264110196137580126906204018533800', '83265065348431602879537003312633461900'],
1834
+ ['6933071107478585245042253386666659991309285264110196137580126906204018533801', '83265065348431602879537003312633461901'],
1835
+ ['1579670801917993723309858041679990418433600770326208765934116379197768903056', '39745072674710178762237903560835952916'],
1836
+ ['1579670801917993723309858041679990418513090915675629123458592186319440808888', '39745072674710178762237903560835952916'],
1837
+ ['1579670801917993723309858041679990418513090915675629123458592186319440808889', '39745072674710178762237903560835952917'],
1838
+ ['681867337215944596936584982759400170727379727957999719338051977506244355625', '26112589630596667363860934899092645325'],
1839
+ ['681867337215944596936584982759400170779604907219193054065773847304429646275', '26112589630596667363860934899092645325'],
1840
+ ['681867337215944596936584982759400170779604907219193054065773847304429646276', '26112589630596667363860934899092645326'],
1841
+ ['288453689043393924123357086972242613663177706471101442929325163584978377458225', '537078848069251303040109060485183727865'],
1842
+ ['288453689043393924123357086972242613664251864167239945535405381705948744913955', '537078848069251303040109060485183727865'],
1843
+ ['288453689043393924123357086972242613664251864167239945535405381705948744913956', '537078848069251303040109060485183727866'],
1844
+ ['195356853506305520718626478206756382507801939519785697420547945042825319176129', '441991915657182038371378633304634321377'],
1845
+ ['195356853506305520718626478206756382508685923351100061497290702309434587818883', '441991915657182038371378633304634321377'],
1846
+ ['195356853506305520718626478206756382508685923351100061497290702309434587818884', '441991915657182038371378633304634321378'],
1847
+ ['171318600916753697429051575925878633930439101417068058777561592608661184180625', '413906512290823587410087929387066009175'],
1848
+ ['171318600916753697429051575925878633931266914441649705952381768467435316198975', '413906512290823587410087929387066009175'],
1849
+ ['171318600916753697429051575925878633931266914441649705952381768467435316198976', '413906512290823587410087929387066009176'],
1850
+ ['921093761539400396463886664522151015280465523566321840991339256462222570006049', '959736297916985317802888407093394929007'],
1851
+ ['921093761539400396463886664522151015282384996162155811626945033276409359864063', '959736297916985317802888407093394929007'],
1852
+ ['921093761539400396463886664522151015282384996162155811626945033276409359864064', '959736297916985317802888407093394929008'],
1853
+ ['95109948153362184845030342755869423838311917496546178503410149505934962822401', '308399008029147501090828356257276909951'],
1854
+ ['95109948153362184845030342755869423838928715512604473505591806218449516642303', '308399008029147501090828356257276909951'],
1855
+ ['95109948153362184845030342755869423838928715512604473505591806218449516642304', '308399008029147501090828356257276909952'],
1856
+ ['19331455316972407468074740850649574350712359000359926791488814669406316705438096', '4396755089491841080442863075541933084436'],
1857
+ ['19331455316972407468074740850649574350721152510538910473649700395557400571606968', '4396755089491841080442863075541933084436'],
1858
+ ['19331455316972407468074740850649574350721152510538910473649700395557400571606969', '4396755089491841080442863075541933084437'],
1859
+ ['79265978575272061761010812898504289157311811916595218347414644480274502855387716', '8903144308348150197415041401715992316846'],
1860
+ ['79265978575272061761010812898504289157329618205211914647809474563077934840021408', '8903144308348150197415041401715992316846'],
1861
+ ['79265978575272061761010812898504289157329618205211914647809474563077934840021409', '8903144308348150197415041401715992316847'],
1862
+ ['18253381792846313534444974681107507939609666705140666138048641067680220712870544', '4272397663238560654482324050372517154612'],
1863
+ ['18253381792846313534444974681107507939618211500467143259357605715780965747179768', '4272397663238560654482324050372517154612'],
1864
+ ['18253381792846313534444974681107507939618211500467143259357605715780965747179769', '4272397663238560654482324050372517154613'],
1865
+ ['34902249932301330884717409262136201131799911786648110181019008640668850248149889', '5907812618245549169232055936851452816833'],
1866
+ ['34902249932301330884717409262136201131811727411884601279357472752542553153783555', '5907812618245549169232055936851452816833'],
1867
+ ['34902249932301330884717409262136201131811727411884601279357472752542553153783556', '5907812618245549169232055936851452816834'],
1868
+ ['2599345980007138866704208379685556534258757776044753601160948822029798157394521', '1612248733913951277041847563008484168539'],
1869
+ ['2599345980007138866704208379685556534261982273512581503715032517155815125731599', '1612248733913951277041847563008484168539'],
1870
+ ['2599345980007138866704208379685556534261982273512581503715032517155815125731600', '1612248733913951277041847563008484168540'],
1871
+ ['5316322030460586450936871958946919636668068288991234947266697538297768830115066084', '72913112884175960485473057702832007114922'],
1872
+ ['5316322030460586450936871958946919636668214115217003299187668484413174494129295928', '72913112884175960485473057702832007114922'],
1873
+ ['5316322030460586450936871958946919636668214115217003299187668484413174494129295929', '72913112884175960485473057702832007114923'],
1874
+ ['8002778973791813108451518291518896929427763054970205412144571951733372499281017601', '89458252686891962949549637560732937788801'],
1875
+ ['8002778973791813108451518291518896929427941971475579196070471051008493965156595203', '89458252686891962949549637560732937788801'],
1876
+ ['8002778973791813108451518291518896929427941971475579196070471051008493965156595204', '89458252686891962949549637560732937788802'],
1877
+ ['204434819803436425073091821729105629106597079412374857081154364351611450036288004', '14298070492322956269314619104943213072002'],
1878
+ ['204434819803436425073091821729105629106625675553359502993692993589821336462432008', '14298070492322956269314619104943213072002'],
1879
+ ['204434819803436425073091821729105629106625675553359502993692993589821336462432009', '14298070492322956269314619104943213072003'],
1880
+ ['248985683905018963214400101508836326950598468017331056913175271121208335269369616', '15779280208711009616855603241137879133796'],
1881
+ ['248985683905018963214400101508836326950630026577748478932408982327690611027637208', '15779280208711009616855603241137879133796'],
1882
+ ['248985683905018963214400101508836326950630026577748478932408982327690611027637209', '15779280208711009616855603241137879133797'],
1883
+ ['9931466785180918581453369553241893953494729509958339130768488436428313616867737664', '99656744805261016419561454808199789423608'],
1884
+ ['9931466785180918581453369553241893953494928823447949652801327559337930016446584880', '99656744805261016419561454808199789423608'],
1885
+ ['9931466785180918581453369553241893953494928823447949652801327559337930016446584881', '99656744805261016419561454808199789423609'],
1886
+ ['571034337207963083686644289650754887712756826847796234542618077049856839883774610496', '755668139600951472909394170487042707063864'],
1887
+ ['571034337207963083686644289650754887712758338184075436445563895838197813969188738224', '755668139600951472909394170487042707063864'],
1888
+ ['571034337207963083686644289650754887712758338184075436445563895838197813969188738225', '755668139600951472909394170487042707063865'],
1889
+ ['43282087429518774838368965030190873132157640943271155661308846536619714287766015625', '208043474854461068334845359605621664088125'],
1890
+ ['43282087429518774838368965030190873132158057030220864583445516227338925531094191875', '208043474854461068334845359605621664088125'],
1891
+ ['43282087429518774838368965030190873132158057030220864583445516227338925531094191876', '208043474854461068334845359605621664088126'],
1892
+ ['417927142998078702077756962900654390278806646288750249869048008644489266148390976576', '646472847842876307508176358984831821937976'],
1893
+ ['417927142998078702077756962900654390278807939234445935621663024997207235812034852528', '646472847842876307508176358984831821937976'],
1894
+ ['417927142998078702077756962900654390278807939234445935621663024997207235812034852529', '646472847842876307508176358984831821937977'],
1895
+ ['57289022864599235425935956369596297021969148801199969985249642058425056660901854081', '239351254152969157626674463098033150396991'],
1896
+ ['57289022864599235425935956369596297021969627503708275923564895407351252727202648063', '239351254152969157626674463098033150396991'],
1897
+ ['57289022864599235425935956369596297021969627503708275923564895407351252727202648064', '239351254152969157626674463098033150396992'],
1898
+ ['388204130919598896854532928319816854683262176908475545926963148518011088548336100', '19702896510909224609070086389295007347690'],
1899
+ ['388204130919598896854532928319816854683301582701497364376181288690789678563031480', '19702896510909224609070086389295007347690'],
1900
+ ['388204130919598896854532928319816854683301582701497364376181288690789678563031481', '19702896510909224609070086389295007347691'],
1901
+ ['17641213493582550358331598783756045983107635305125558424245083335221980342711574945924', '4200144461037328458609200843143798139299618'],
1902
+ ['17641213493582550358331598783756045983107643705414480498902000553623666630307853545160', '4200144461037328458609200843143798139299618'],
1903
+ ['17641213493582550358331598783756045983107643705414480498902000553623666630307853545161', '4200144461037328458609200843143798139299619'],
1904
+ ['10480850478210993041934376751763741537950365795671072307889437499081947766082767900625', '3237414165381221816392010300367379458321975'],
1905
+ ['10480850478210993041934376751763741537950372270499403070333070283102548500841684544575', '3237414165381221816392010300367379458321975'],
1906
+ ['10480850478210993041934376751763741537950372270499403070333070283102548500841684544576', '3237414165381221816392010300367379458321976'],
1907
+ ['18912401257760832817656385679644608795185415305426367246326490097108178277089565964900', '4348839070115245459938703154127996458785930'],
1908
+ ['18912401257760832817656385679644608795185424003104507476817409974514486533082483536760', '4348839070115245459938703154127996458785930'],
1909
+ ['18912401257760832817656385679644608795185424003104507476817409974514486533082483536761', '4348839070115245459938703154127996458785931'],
1910
+ ['4058130180100830389999063645300769577286055319083847709319631222394835048000563913616', '2014480126509276434961389427500807039909204'],
1911
+ ['4058130180100830389999063645300769577286059348044100727872501145173690049614643732024', '2014480126509276434961389427500807039909204'],
1912
+ ['4058130180100830389999063645300769577286059348044100727872501145173690049614643732025', '2014480126509276434961389427500807039909205'],
1913
+ ['33468184484233190391618513143907824051569626629768396502905028100863488827541016357225', '5785169356573166941812342062118994545501165'],
1914
+ ['33468184484233190391618513143907824051569638200107109649238911725547613065530107359555', '5785169356573166941812342062118994545501165'],
1915
+ ['33468184484233190391618513143907824051569638200107109649238911725547613065530107359556', '5785169356573166941812342062118994545501166'],
1916
+ ['1186174880095419715607318419843788127322568925641042677386667373975880777802263411393536', '34440889653076903576703209294470985379444256'],
1917
+ ['1186174880095419715607318419843788127322568994522821983540474527382299366744234170282048', '34440889653076903576703209294470985379444256'],
1918
+ ['1186174880095419715607318419843788127322568994522821983540474527382299366744234170282049', '34440889653076903576703209294470985379444257'],
1919
+ ['1869407664810972914760141576011747496493758522541997263089274909609818581502013012539601', '43236647242946265649799966945038223493750199'],
1920
+ ['1869407664810972914760141576011747496493758609015291748981806209209752471578460000039999', '43236647242946265649799966945038223493750199'],
1921
+ ['1869407664810972914760141576011747496493758609015291748981806209209752471578460000040000', '43236647242946265649799966945038223493750200'],
1922
+ ['4306248093986950964567669268958861794743230041121457387922204677053975232405051053143025', '65622009219369007099774314994059599547494695'],
1923
+ ['4306248093986950964567669268958861794743230172365475826660218876602605220524250148132415', '65622009219369007099774314994059599547494695'],
1924
+ ['4306248093986950964567669268958861794743230172365475826660218876602605220524250148132416', '65622009219369007099774314994059599547494696'],
1925
+ ['142958974763379486489798376541073126699563800627039429166077132824711226669748693162209', '11956545268737934506570289899105912433421297'],
1926
+ ['142958974763379486489798376541073126699563824540129966641946145965291024881573560004803', '11956545268737934506570289899105912433421297'],
1927
+ ['142958974763379486489798376541073126699563824540129966641946145965291024881573560004804', '11956545268737934506570289899105912433421298'],
1928
+ ['5924043074304444391210747851995027637083074459394928466831722415634829619104396893068176', '76967805440355673370818024381288105628528724'],
1929
+ ['5924043074304444391210747851995027637083074613330539347543069157270878381680608150125624', '76967805440355673370818024381288105628528724'],
1930
+ ['5924043074304444391210747851995027637083074613330539347543069157270878381680608150125625', '76967805440355673370818024381288105628528725'],
1931
+ ['692647042392925303434391597094843086706651167173473530228926147229989661906443247661192976', '832254193376594110047678950757920520714968676'],
1932
+ ['692647042392925303434391597094843086706651168837981916982114367325347563422284289091130328', '832254193376594110047678950757920520714968676'],
1933
+ ['692647042392925303434391597094843086706651168837981916982114367325347563422284289091130329', '832254193376594110047678950757920520714968677'],
1934
+ ['63418927703603396384251230391169377358870766926264966118026529953350707524741421056456161', '251831149192476577524577782662609731668640369'],
1935
+ ['63418927703603396384251230391169377358870767429927264502979685002506272849960884393736899', '251831149192476577524577782662609731668640369'],
1936
+ ['63418927703603396384251230391169377358870767429927264502979685002506272849960884393736900', '251831149192476577524577782662609731668640370'],
1937
+ ['84173934762470484045776658803140625724430904400114977656227228331290197573900111299728676', '290127445724237685478628941387635987912451526'],
1938
+ ['84173934762470484045776658803140625724430904980369869104702599288548080349172087124631728', '290127445724237685478628941387635987912451526'],
1939
+ ['84173934762470484045776658803140625724430904980369869104702599288548080349172087124631729', '290127445724237685478628941387635987912451527'],
1940
+ ['241361038321369463167942286580817659556660094711530196521279493146351719422610472610272609', '491285088641380874516359084346407133019022897'],
1941
+ ['241361038321369463167942286580817659556660095694100373804041242179069888115424738648318403', '491285088641380874516359084346407133019022897'],
1942
+ ['241361038321369463167942286580817659556660095694100373804041242179069888115424738648318404', '491285088641380874516359084346407133019022898'],
1943
+ ['517176462045529989620702018222975120090314182384304448758922583345467659488721121496429225', '719149818915036638988212861879727351601847565'],
1944
+ ['517176462045529989620702018222975120090314183822604086588995861321893383248175824700124355', '719149818915036638988212861879727351601847565'],
1945
+ ['517176462045529989620702018222975120090314183822604086588995861321893383248175824700124356', '719149818915036638988212861879727351601847566'],
1946
+ ['77611022182569680065221018033132479141166512436949302435927867888665269025756976722964990841', '8809711810415235147462139161930461303380344971'],
1947
+ ['77611022182569680065221018033132479141166512454568726056758338183589547349617899329725680783', '8809711810415235147462139161930461303380344971'],
1948
+ ['77611022182569680065221018033132479141166512454568726056758338183589547349617899329725680784', '8809711810415235147462139161930461303380344972'],
1949
+ ['6105408765553994361209114516342314667656879868595988990330444228342133209919341402497612900', '2470912537010161831197388767291893513920213770'],
1950
+ ['6105408765553994361209114516342314667656879873537814064350767890736910744503128430338040440', '2470912537010161831197388767291893513920213770'],
1951
+ ['6105408765553994361209114516342314667656879873537814064350767890736910744503128430338040441', '2470912537010161831197388767291893513920213771'],
1952
+ ['90701786360131891675282105453602007239665462813393298839266200083003999684896009231900541761', '9523748545616473366260116123335442806957838431'],
1953
+ ['90701786360131891675282105453602007239665462832440795930499146815524231931566894845816218623', '9523748545616473366260116123335442806957838431'],
1954
+ ['90701786360131891675282105453602007239665462832440795930499146815524231931566894845816218624', '9523748545616473366260116123335442806957838432'],
1955
+ ['65323751401133593272677920818977066639472955689716002480072016807758009911894964398074221636', '8082311018584572712389536725132408571687355694'],
1956
+ ['65323751401133593272677920818977066639472955705880624517241162232537083362159781541448933024', '8082311018584572712389536725132408571687355694'],
1957
+ ['65323751401133593272677920818977066639472955705880624517241162232537083362159781541448933025', '8082311018584572712389536725132408571687355695'],
1958
+ ['54888850556449896314370999310468417973690137670860368033970930193923337744682096321526909321', '7408701003310222419788126612344084182212588611'],
1959
+ ['54888850556449896314370999310468417973690137685677770040591375033499590969370264685952086543', '7408701003310222419788126612344084182212588611'],
1960
+ ['54888850556449896314370999310468417973690137685677770040591375033499590969370264685952086544', '7408701003310222419788126612344084182212588612'],
1961
+ ['2805085217054754253789444062542634634800093806651719072914037849606695181828139974525774321216', '52963055208841136620374558431841622364185138904'],
1962
+ ['2805085217054754253789444062542634634800093806757645183331720122847444298691823219254144599024', '52963055208841136620374558431841622364185138904'],
1963
+ ['2805085217054754253789444062542634634800093806757645183331720122847444298691823219254144599025', '52963055208841136620374558431841622364185138905'],
1964
+ ['1160568960830598642226220064123168954080961712013862945053127684556984147281594628487247009409', '34067124340492824200405891794016084650299718847'],
1965
+ ['1160568960830598642226220064123168954080961712081997193734113332957795930869626797787846447103', '34067124340492824200405891794016084650299718847'],
1966
+ ['1160568960830598642226220064123168954080961712081997193734113332957795930869626797787846447104', '34067124340492824200405891794016084650299718848'],
1967
+ ['124505361771365706389189800193135630498052202514496166178932088454657696893428061453489005584', '11158197066343904036990752059839856835208279172'],
1968
+ ['124505361771365706389189800193135630498052202536812560311619896528639201013107775123905563928', '11158197066343904036990752059839856835208279172'],
1969
+ ['124505361771365706389189800193135630498052202536812560311619896528639201013107775123905563929', '11158197066343904036990752059839856835208279173'],
1970
+ ['8304391676065346969717869193750447720841513935376871747395147291005945252957072474745223924900', '91128435057699454436963842029258931771642571930'],
1971
+ ['8304391676065346969717869193750447720841513935559128617510546199879872937015590338288509068760', '91128435057699454436963842029258931771642571930'],
1972
+ ['8304391676065346969717869193750447720841513935559128617510546199879872937015590338288509068761', '91128435057699454436963842029258931771642571931'],
1973
+ ['3902633675982472936031277376575750479219313797204897526330941750565757566042240677294833640976', '62471062708925265536995715391198772286875632324'],
1974
+ ['3902633675982472936031277376575750479219313797329839651748792281639748996824638221868584905624', '62471062708925265536995715391198772286875632324'],
1975
+ ['3902633675982472936031277376575750479219313797329839651748792281639748996824638221868584905625', '62471062708925265536995715391198772286875632325'],
1976
+ ['21803189113281615247645689642554433787955300436727779524987566434496560052640713833839771848809', '147659029907695165135263001196567750660989708947'],
1977
+ ['21803189113281615247645689642554433787955300437023097584802956764767086055033849335161751266703', '147659029907695165135263001196567750660989708947'],
1978
+ ['21803189113281615247645689642554433787955300437023097584802956764767086055033849335161751266704', '147659029907695165135263001196567750660989708948'],
1979
+ ['765773631185413773891853587035522811215936001201156164967993252197672361266093168217637840800625', '875084927984372139644261680745245536779196496025'],
1980
+ ['765773631185413773891853587035522811215936001202906334823961996476960884627583659291196233792675', '875084927984372139644261680745245536779196496025'],
1981
+ ['765773631185413773891853587035522811215936001202906334823961996476960884627583659291196233792676', '875084927984372139644261680745245536779196496026'],
1982
+ ['371531253548731146505174144638678761062942262073337722044484956271277190798021717224921126356624', '609533636109387441986227427959683991839011782068'],
1983
+ ['371531253548731146505174144638678761062942262074556789316703731155249645653941085208599149920760', '609533636109387441986227427959683991839011782068'],
1984
+ ['371531253548731146505174144638678761062942262074556789316703731155249645653941085208599149920761', '609533636109387441986227427959683991839011782069'],
1985
+ ['32639765347874160297815057000511241042881990523574135639577516269227137979270282014943162493161', '180664787238338617809927067472657959412705501869'],
1986
+ ['32639765347874160297815057000511241042881990523935465214054193504846992114215597933768573496899', '180664787238338617809927067472657959412705501869'],
1987
+ ['32639765347874160297815057000511241042881990523935465214054193504846992114215597933768573496900', '180664787238338617809927067472657959412705501870'],
1988
+ ['23312804018277899268530151932487478598118645419296370443140824162402663914524726804469078709025', '152685310420740538469311655525476411276716730095'],
1989
+ ['23312804018277899268530151932487478598118645419601741063982305239341287225575679627022512169215', '152685310420740538469311655525476411276716730095'],
1990
+ ['23312804018277899268530151932487478598118645419601741063982305239341287225575679627022512169216', '152685310420740538469311655525476411276716730096'],
1991
+ ['69351939896058034711498082880502238045919014432567876454734811966028586293551025867711349695480441', '8327781210866315423454045118194686369495352533771'],
1992
+ ['69351939896058034711498082880502238045919014432584532017156544596875494383787415240450340400547983', '8327781210866315423454045118194686369495352533771'],
1993
+ ['69351939896058034711498082880502238045919014432584532017156544596875494383787415240450340400547984', '8327781210866315423454045118194686369495352533772'],
1994
+ ['56907419683049340072215388152597682083224395922699571395667588185898365170014916921330096015050884', '7543700662344002371027341442602779762847104806622'],
1995
+ ['56907419683049340072215388152597682083224395922714658796992276190640419852900122480855790224664128', '7543700662344002371027341442602779762847104806622'],
1996
+ ['56907419683049340072215388152597682083224395922714658796992276190640419852900122480855790224664129', '7543700662344002371027341442602779762847104806623'],
1997
+ ['1163525248981521754155547339230838194099208908132096593234853200207208035365529397606592383400336', '1078668275690687843154790865870705804593431876844'],
1998
+ ['1163525248981521754155547339230838194099208908134253929786234575893517617097270809215779247154024', '1078668275690687843154790865870705804593431876844'],
1999
+ ['1163525248981521754155547339230838194099208908134253929786234575893517617097270809215779247154025', '1078668275690687843154790865870705804593431876845'],
2000
+ ['12630009931573082897907144855573901252532449094542217468986509301292277005832281659959934465254400', '3553872526072521203015975245855936611531238601120'],
2001
+ ['12630009931573082897907144855573901252532449094549325214038654343698308956323993533182996942456640', '3553872526072521203015975245855936611531238601120'],
2002
+ ['12630009931573082897907144855573901252532449094549325214038654343698308956323993533182996942456641', '3553872526072521203015975245855936611531238601121'],
2003
+ ['31255308963169979605103962253255036593975285646828038303401111783018980508885388211539730531736976', '5590644771685103192691707139464277920149086765676'],
2004
+ ['31255308963169979605103962253255036593975285646839219592944481989404363923164316767380028705268328', '5590644771685103192691707139464277920149086765676'],
2005
+ ['31255308963169979605103962253255036593975285646839219592944481989404363923164316767380028705268329', '5590644771685103192691707139464277920149086765677'],
2006
+ ['8628012985404686018689218847909668804260178206412486603741772756323555243760489710208140383228648196', '92887098056752133732654744820968248061511732728514'],
2007
+ ['8628012985404686018689218847909668804260178206412672377937886260591020553250131646704263406694105224', '92887098056752133732654744820968248061511732728514'],
2008
+ ['8628012985404686018689218847909668804260178206412672377937886260591020553250131646704263406694105225', '92887098056752133732654744820968248061511732728515'],
2009
+ ['9233511524782328316011754355906749687042442384057568340621550432564122836332981092655854023226646089', '96091162573788898435727389725088702432559537501283'],
2010
+ ['9233511524782328316011754355906749687042442384057760522946698010360994291112431270060719142301648655', '96091162573788898435727389725088702432559537501283'],
2011
+ ['9233511524782328316011754355906749687042442384057760522946698010360994291112431270060719142301648656', '96091162573788898435727389725088702432559537501284'],
2012
+ ['453765858005120177768073445581083997020624166557446581526841386118834645505297210629607793706393856', '21301780629917306933323409392321012226117710104816'],
2013
+ ['453765858005120177768073445581083997020624166557489185088101220732701292324081852654060029126603488', '21301780629917306933323409392321012226117710104816'],
2014
+ ['453765858005120177768073445581083997020624166557489185088101220732701292324081852654060029126603489', '21301780629917306933323409392321012226117710104817'],
2015
+ ['1371661154627246967424438399063581804666179749323634366508032096471110921410597239232159814550961124', '37035944089860149903963455856570016412483527052182'],
2016
+ ['1371661154627246967424438399063581804666179749323708438396211816770918848322310379264984781605065488', '37035944089860149903963455856570016412483527052182'],
2017
+ ['1371661154627246967424438399063581804666179749323708438396211816770918848322310379264984781605065489', '37035944089860149903963455856570016412483527052183'],
2018
+ ['370256269805896436402015708175373292783056837812420632207201736440955067457713055190230384049843049', '19242044325016415375787142063732125294673656555757'],
2019
+ ['370256269805896436402015708175373292783056837812459116295851769271706641741840519440819731362954563', '19242044325016415375787142063732125294673656555757'],
2020
+ ['370256269805896436402015708175373292783056837812459116295851769271706641741840519440819731362954564', '19242044325016415375787142063732125294673656555758'],
2021
+ ];
2022
+ }
2023
+
2024
+ public function testSqrtOfNegativeNumber() : void
2025
+ {
2026
+ $number = BigInteger::of(-1);
2027
+ $this->expectException(NegativeNumberException::class);
2028
+ $number->sqrt();
2029
+ }
2030
+
2031
+ /**
2032
+ * @dataProvider providerAbs
2033
+ *
2034
+ * @param string $number The number as a string.
2035
+ * @param string $expected The expected absolute result.
2036
+ */
2037
+ public function testAbs(string $number, string $expected) : void
2038
+ {
2039
+ self::assertBigIntegerEquals($expected, BigInteger::of($number)->abs());
2040
+ }
2041
+
2042
+ public function providerAbs() : array
2043
+ {
2044
+ return [
2045
+ ['0', '0'],
2046
+ ['123456789012345678901234567890', '123456789012345678901234567890'],
2047
+ ['-123456789012345678901234567890', '123456789012345678901234567890'],
2048
+ ];
2049
+ }
2050
+
2051
+ /**
2052
+ * @dataProvider providerNegated
2053
+ *
2054
+ * @param string $number The number to negate as a string.
2055
+ * @param string $expected The expected negated result.
2056
+ */
2057
+ public function testNegated(string $number, string $expected) : void
2058
+ {
2059
+ self::assertBigIntegerEquals($expected, BigInteger::of($number)->negated());
2060
+ }
2061
+
2062
+ public function providerNegated() : array
2063
+ {
2064
+ return [
2065
+ ['0', '0'],
2066
+ ['123456789012345678901234567890', '-123456789012345678901234567890'],
2067
+ ['-123456789012345678901234567890', '123456789012345678901234567890'],
2068
+ ];
2069
+ }
2070
+
2071
+ /**
2072
+ * @dataProvider providerOr
2073
+ *
2074
+ * @param string $a The base number as a string.
2075
+ * @param string $b The second operand as a string.
2076
+ * @param string $c The expected result.
2077
+ */
2078
+ public function testOr(string $a, string $b, string $c) : void
2079
+ {
2080
+ self::assertBigIntegerEquals($c, BigInteger::of($a)->or($b));
2081
+ }
2082
+
2083
+ public function providerOr() : array
2084
+ {
2085
+ return [
2086
+ ['-1', '-2', '-1'],
2087
+ ['1', '-2', '-1'],
2088
+ ['-1', '2', '-1'],
2089
+ ['0', '1', '1'],
2090
+ ['123456789', '2', '123456791'],
2091
+ ['123456789012345678901234567890', '5', '123456789012345678901234567895'],
2092
+
2093
+ // +/+
2094
+ ['5394692623120841541359442506121617881401403431187', '9766511485175005460536', '5394692623120841541359442515868493073997685913915'],
2095
+ ['13019371322243819899204272493521124405791800889', '3726873297591390232697342938795296319136', '13019372133120279604421814277427131266071789241'],
2096
+ ['825328913860854183466591', '820522975067667161505095715672113', '820522975740678967606674026518143'],
2097
+ ['7315468442240573482143183', '5515620804916021008917193641105420503', '5515620804918462921325666985224175071'],
2098
+ ['110104465264058103889358298866', '94814454566057673772310777098551244', '94814554220241714731352195897180158'],
2099
+ ['582122067691582101691266880169169117', '55049524716805317255574656192191', '582165366513537784238545389955702527'],
2100
+ ['44873367566918874237638126', '9409284695426246790492523165', '9409370989367316235989229567'],
2101
+ ['64440906628912978316185121528516412439581546252', '81625941605259372046980969698971221793201400420812216', '81625958913430687266413542869832062998782644017813436'],
2102
+ ['61190858896401275408368039585731416556', '77528509846707811172472891497150', '61190890789450813957866744619030404094'],
2103
+ ['16370447908750281436283735', '33298946904845025350531059039688786', '33298946921165556207545256032852823'],
2104
+
2105
+ // +/-
2106
+ ['629228300462038209944858167835301131122621385', '-24883098317384873963133964889006559124430650726905548810', '-24883098316846256827607757635214967359849628880391897089'],
2107
+ ['775691429999776584456355266541756753945050', '-44019102118444435028320990611417008365859', '-106341809525727913368330013670930268193'],
2108
+ ['23036338384780646740896760425349240', '-5478898094914207535986208043291517993', '-5457429153187938999914259991937295361'],
2109
+ ['71118708446231992585781812506893296427746901059', '-1538512593651669138154724', '-21301756145772576637089'],
2110
+ ['95761531088891927652144172762302643791728575066056439', '-73813927170349582735449', '-62002966777642928920585'],
2111
+ ['147250036603078668581525429762829', '-361868247492494445272460684932230002238896', '-361868247487223141650087293986311332349091'],
2112
+ ['99930782821428633178253476728280061597459150050275', '-753226818836998475961273398390981', '-22821458929931233658600654659589'],
2113
+ ['875039889838938241455632936393708', '-74753436502079272149039840217097829379635018', '-74753436502056413508822744073804860617008130'],
2114
+ ['44473056973336336084179028836', '-642876954476407938176346144700252080168226421757640', '-642876954476407938176342871835826873856675947762820'],
2115
+ ['10832413402209480147931243970039726', '-93114160710811589646365329687673290', '-92992446445992844023796182323654722'],
2116
+
2117
+ // -/+
2118
+ ['-58282712640531681730833687888223654527698209637332654', '42073831540395345067530857', '-58282712640531681730833687848629557121142117902623877'],
2119
+ ['-1084275441589706957474009274660708408270082347887678', '9981430101411912941313315601191084553434386669517100', '-94107724785771989656363150071297242939909531223058'],
2120
+ ['-598777304188523652658494946327505334467783703319', '41796915801148574135327226262820013943232613155788027', '-552389486488495482683109572827418077709951314693'],
2121
+ ['-37924152083831463156', '11645291103528743935841065217614462310970547876719983680210', '-724275812307698722'],
2122
+ ['-85805203640767691526502704', '896583742459515926613645044246150', '-8089494556653456495974698'],
2123
+ ['-898723825644461589477861601', '966718006713828880001720445', '-271140206795741014665988225'],
2124
+ ['-4803554725846075946809233272342849380', '3789669181482167533795', '-4803554725846075847653480259198920449'],
2125
+ ['-8239281675053995153625856701645533046744884636738', '195355546009266013074942651597617574642246792', '-8239281494701588116574460878233761583302994167874'],
2126
+ ['-2461312127713272017388112641949224482917501911058334', '218828275523635383548866565214082261313061778728394264714492', '-964642997122122969610553507645301283121473429586690'],
2127
+ ['-15681959488652631674', '73904389130453115377', '-15564582155250048521'],
2128
+
2129
+ // -/-
2130
+ ['-71023078211213600373008149300531297714178520062731', '-853926183433843136944713294041079955', '-736401078260378233748751535570947'],
2131
+ ['-27149910991078057927341430954047198256402084022', '-14438392862108994971173507', '-4004612905874255759343745'],
2132
+ ['-238860647199613977017', '-6113291898513098650624035878857504327842', '-5909070255575269537'],
2133
+ ['-687121238445111757141748', '-65287940446908065749910389869762916518', '-4725401435649813786786'],
2134
+ ['-51999011814383818848599396253370345902663465788294927', '-514426331389927533029', '-479687516219085193477'],
2135
+ ['-546583149661189506949', '-1886943709420620214803722', '-315919918989248627969'],
2136
+ ['-8636166193965613127594731284', '-8181172184899045690506766177618298431021363952049', '-3335591938529949537265574161'],
2137
+ ['-94490697244560460969748233110763906395003420647076515', '-723986053083944708227437327714382632737927996062236', '-206117762652633881638126746265326880615590132920835'],
2138
+ ['-7227021890466860512716899555631477118800822', '-9868452730291944167866341531306323590', '-8517968707344152068783650362697974406'],
2139
+ ['-886177102305364710710271549944886', '-619676933192435363578115557006420998424428632929783759', '-196486036766831552439772004779013'],
2140
+ ];
2141
+ }
2142
+
2143
+ /**
2144
+ * @dataProvider providerAnd
2145
+ *
2146
+ * @param string $a The base number as a string.
2147
+ * @param string $b The second operand as a string.
2148
+ * @param string $c The expected result.
2149
+ */
2150
+ public function testAnd(string $a, string $b, string $c) : void
2151
+ {
2152
+ self::assertBigIntegerEquals($c, BigInteger::of($a)->and($b));
2153
+ }
2154
+
2155
+ public function providerAnd() : array
2156
+ {
2157
+ return [
2158
+ ['-1', '-2', '-2'],
2159
+ ['1', '-2', '0'],
2160
+ ['-1', '2', '2'],
2161
+ ['0', '1', '0'],
2162
+ ['123456789', '123456787', '123456785'],
2163
+ ['-255', '255', '1'],
2164
+ ['-65535', '65535', '1'],
2165
+ ['123456789012345678901234567890', '123456789012345678901234567880', '123456789012345678901234567872'],
2166
+ ['-123456789012345678', '123456789012345678', '2'],
2167
+ ['-123456789012345678901234567890', '123456789012345678901234567880', '8'],
2168
+ ['-123456789012345678901234567890', '123456789012345678901234567890', '2'],
2169
+
2170
+ // +/+
2171
+ ['9540274336583084975562289722883526775521835932895037762835', '957696937540728677043370494807703921521803820', '956215995421898870832092642430941754382745600'],
2172
+ ['665165726101105766657686931651143608914582782', '4447574838980484593141693556584', '1901555884282179808129622475880'],
2173
+ ['790343628306512069923527702470983342686', '62298850543399391744839187137607', '20307169700729362621431664508998'],
2174
+ ['2129188417498745891659300713194793359728416786577409728257', '13131659959207622018684646910022554990063156546254428690', '12356306984463677619589352676276775643362583267126565376'],
2175
+ ['104310239039582621686', '6446718309080309833322276220218494992', '76135640055047897104'],
2176
+ ['74868295422704959401678579346171048', '867186067426411270613182153780877', '856945737422567889012791074907272'],
2177
+ ['6937657292522823097429594605267918559241308579775080', '216218931239976107136182640332044026', '3250891995280997169353922931081832'],
2178
+ ['7906079216913996792813', '4742451651607606791972951532992811', '230746713170494308649'],
2179
+ ['293688858487958770805571838692', '8677568912502877580987165764167283758651602410275293', '247781448091522189113454887108'],
2180
+ ['72233549478210553977593718216', '316088176499879291090502991526073942544850660245451', '12734829629065561014968001992'],
2181
+
2182
+ // +/-
2183
+ ['2664177563192220439082233', '-497575612689987685525145701582641566', '2588024780851115490075744'],
2184
+ ['72302616794456840461076482624687', '-7920544542105677637241746439802629410560020574577414593', '51978658148206026594900129745967'],
2185
+ ['58011260275322692847', '-6123749825659279738219243668730082', '57939162772413645838'],
2186
+ ['466382812961846768942257', '-5749717770169572418738550644839', '466336614426915108887697'],
2187
+ ['60996924305709811365429943772752206951836061719477499', '-46952464788284959785687905299628715212736', '60996924305663053101630907874782654442194351887089728'],
2188
+ ['1271298968079615636311319759', '-7076044481917178328978459111269631067437408434807094275466', '9671425457443162481033286'],
2189
+ ['6654184611673948944936810250930287210552163122670575877', '-511128347138119909516013001952844', '6654184611673948944936485472331537539300894385725579524'],
2190
+ ['697102292326392768156034363', '-385816895302447426012908574281578202973', '77527105904576612288962595'],
2191
+ ['926786641478132770994056080463057595622227100625806678987087', '-4322855505705341813979014306030462108040', '926786641478132770989781249376882824272551951998480271052872'],
2192
+ ['927695357427113145993764093616313117', '-11115367682761386491887989227580455376084253492', '251836538845141304306589183586877452'],
2193
+
2194
+ // -/+
2195
+ ['-848481030369881011367', '24459162697579073867788448115909', '24459162697494549701243157153857'],
2196
+ ['-34065802561923171904150684209458120004', '4019358484940611693618982930850498281249420456156830959485', '4019358484940611693617652381249270184290140195729437360700'],
2197
+ ['-98954587067690432154450092126188399456988744363401', '7655495624455877244961837619471607354199154315816566', '7558944991169524242286724530424642134143850575839862'],
2198
+ ['-868644810088092713567148601735963298182552679670410544', '82858149617006726392344736421399315', '8137732778129228141094120234418704'],
2199
+ ['-998663980250596578114821117767', '244259108311520229266439571373536844773689777602030922967', '244259108311520229266439570374874161412287861875548399761'],
2200
+ ['-1248259686272528973901614707528215891498219194', '655960081606886139163780', '3646115001589090238468'],
2201
+ ['-64227536611226610452440126782979674374285173975671002634662', '461341395556252503179771531031624891465951855470266', '85686368347052340500241906477444420549161344263706'],
2202
+ ['-59791551673394204346327697704196561177891877794', '645966555806444815602615', '605676378409436309569558'],
2203
+ ['-78238580533531033368', '4270126481201125120087', '4192178106247701282880'],
2204
+ ['-24246028315072417932912875604255655638242139918336845', '88698793933327787439447955672549045569403546851781349889', '88698791693808181914782599290752525843380500099683258369'],
2205
+
2206
+ // -/-
2207
+ ['-46546491822650354506208692474', '-6018394977185170090061542472648023760', '-6018395021828699316799393168518602496'],
2208
+ ['-743152617251558809630108680999418964331728228384787849230837', '-486018928970295572717155093024800', '-743152617251558809630108681140478317458875041694533184895488'],
2209
+ ['-4866622764858529488867', '-9537607529046144869970624844191278832590222289361241071473', '-9537607529046144869970624844191278832725160271731278438387'],
2210
+ ['-730775514685831862862019', '-7625523418577177635605525193753328220200935764095710810', '-7625523418577177635605525193754058951651831078253557468'],
2211
+ ['-2495682281115246180115', '-4987103315776729653070191331703716090918578703674535', '-4987103315776729653070191331703794637216039900659639'],
2212
+ ['-5488584277887675655108118932595839273325330416629', '-35229300045153487757488412419836606669940355895', '-5523085971325721180807451421014175245560668484599'],
2213
+ ['-38381423696890807426981559614356456230', '-739182484535059269819467633096483064087898332967634653', '-739182484535059291210108909612231991208362490711672830'],
2214
+ ['-597890573360345150854843009177617022270269706803', '-356012815728552252318079858872451714748749323785869', '-356564984188142681001344514389876040872667286820543'],
2215
+ ['-23463750166518460186485', '-22463992818295711097263710726797562089902730407', '-22463992818295711097263732647933653555539476471'],
2216
+ ['-4720389698935017471106', '-5791089930750302614122639001626417276700', '-5791089930750302617254009841385790242716'],
2217
+ ];
2218
+ }
2219
+
2220
+ /**
2221
+ * @dataProvider providerXor
2222
+ *
2223
+ * @param string $a The base number as a string.
2224
+ * @param string $b The second operand as a string.
2225
+ * @param string $c The expected result.
2226
+ */
2227
+ public function testXor(string $a, string $b, string $c) : void
2228
+ {
2229
+ self::assertBigIntegerEquals($c, BigInteger::of($a)->xor($b));
2230
+ }
2231
+
2232
+ public function providerXor() : array
2233
+ {
2234
+ return [
2235
+ ['-1', '-2', '1'],
2236
+ ['1', '-2', '-1'],
2237
+ ['-1', '2', '-3'],
2238
+ ['0', '1', '1'],
2239
+ ['-83', '173', '-256'],
2240
+ ['-18771', '46765', '-65536'],
2241
+ ['123456789', '123456787', '6'],
2242
+ ['123456789012345678901234567890', '123456789012345678901234567880', '26'],
2243
+
2244
+ // +/+
2245
+ ['41936628898433583900377933376976456781382668201', '37438930022022297882355139442212242', '41936628898407843119376111192570891919127786043'],
2246
+ ['1396562930260915648913', '71641901675063559788952950744943756922652019', '71641901675063559788951904814355699342310626'],
2247
+ ['5516178102046463636096186694651', '875416336636949134319480209741982233245414152081922', '875416336636949134324272999228874694385703653452281'],
2248
+ ['44625554404673588038549694469410638788', '3986527263757904531356805078494718124130202', '3986567880798165849629123513197484710278238'],
2249
+ ['967806838288818008878944294178353817974', '76572892056138061819934', '967806838288817933560480392383696345448'],
2250
+ ['6549960491760248668106', '809972248704249942320679286902130876735', '809972248704249945215832367837518077685'],
2251
+ ['81768549689528295227985831635629126', '19817599042102705952700129285270428899034937', '19817599060488705106871948403348505771766655'],
2252
+ ['51061712813654731819732216707359355', '66692382670293033297443892866698492227594289069400209372', '66692382670293033297492356940600616297078672795457426855'],
2253
+ ['2911271926407417388841130496527454120', '5721716929167795329992995424101009933', '8625837926505651836919858326429320613'],
2254
+ ['250487960291521021073935796160338835400290220715961112221', '730963719206186822116330979615072911065377412384726', '250487661935153548798668340542160754252631389086710550859'],
2255
+
2256
+ // +/-
2257
+ ['315703524235733840821539711472063687', '-66841807242064399137898074', '-315703524297114064979936049584581279'],
2258
+ ['9277446674792088663850794', '-468221831505587189524134735682478879', '-468221831507190080423662165290212405'],
2259
+ ['25248048793307023015625438880440428269421254894139', '-646545451763103268373', '-25248048793307023015625438879795613802044300074032'],
2260
+ ['335324370082663461840497094633353490278304', '-209930584737852772355949', '-335324370082663461668349481746878508148941'],
2261
+ ['47721338528112883273875118081320011400', '-514064818694561791796525208693394326424194951567386', '-514064818694603840468840657747837685067866677419666'],
2262
+ ['759328623799165232926167861149310373966385535771841296', '-646816520151325139126678463083014308430319243677936375445', '-647381293125620242400109462625361980733466505018954892677'],
2263
+ ['6166808730528886865831', '-426783710143127948270328759492197246436605', '-426783710143127948273690847578353176066908'],
2264
+ ['77498570398475696333538111110', '-5075673799000376918718707282635634085023746', '-5075673799000434355613569601920122251640456'],
2265
+ ['22047659110158133001284', '-74320913378607121210', '-22121381026900967571326'],
2266
+ ['5803364274065958314081776638016430551', '-4274229015423103292286737939046', '-5803360773562161501600470160092978099'],
2267
+
2268
+ // -/+
2269
+ ['-219350939601758896616523678389329861570463', '63548322315279018507052841', '-219350939601758950342282130799881889728696'],
2270
+ ['-5175986557609229988', '4562807781300154604786933585136050', '-4562807781300159526169887167051538'],
2271
+ ['-862734998654636443371922824446042207357345563995275488288', '317608759822741357639924588123216895628880482154756290644', '-1173569382701121390549222300360179251785924943446632748108'],
2272
+ ['-291785474648537977564128489162469251745788136086106796831700', '5786510264217139518265184', '-291785474648537977564128489162469247244511035252603664196788'],
2273
+ ['-689232696320162959219689095', '318033535871428535707877013012325978', '-318033536478373294479670092014067933'],
2274
+ ['-548532601216922744036631801709795957', '464214222118222367096184046350871', '-548808886226572611762806251826112612'],
2275
+ ['-2525374855554185527470347476684259136', '44783634414672425382682444859739', '-2525335156275258990485054325291398757'],
2276
+ ['-99017229521698702235373057368702644375364516', '779282291714372043825783864', '-99017229521698702705157919912107724461115292'],
2277
+ ['-4710489498953681316141687031448503', '2560025673790695682768396746333763204153628465907446181227', '-2560025673790695682768397234261771887641640339447134170846'],
2278
+ ['-2183346293342208505308848673968702587335086', '3020876205758828292116264754395150520917505612717', '-3020878389102130545864960825956618914014864271873'],
2279
+
2280
+ // -/-
2281
+ ['-996523196457170777603', '-404534123678048856609187747', '404533718099753040655471008'],
2282
+ ['-88920925457369076369503008991228685035480552065', '-861198439422198824907245698639167235', '88920925456889524433116972809069378460008541570'],
2283
+ ['-41959726569833028356682369416236828694329874', '-58667070061040418591471570920753703169815', '41901315231453792392158501110242583793800455'],
2284
+ ['-53546995034536014873392', '-727312663703395826234974991306249786667844', '727312663703395826276124357261659078733932'],
2285
+ ['-34044215077835894902263474480877183', '-6692590003291305319757462955544', '34050847838851223962321332801038441'],
2286
+ ['-84458180012548319475', '-713807707081754243251117003805750221625293885560131', '713807707081754243251117003805686518886730992598448'],
2287
+ ['-860280316690197636629434822868211047371', '-4686935694950655198346422360359494231305', '5190952310140759138856214711198540086978'],
2288
+ ['-142063436269923412083052305900605223034381146', '-21112042865389423222803894', '142063436269923412065283924632113712290606828'],
2289
+ ['-94892910549951327470288236693704214482009665', '-7883187498538181992212844876690954593546', '94889133411885079989953104317264033746983753'],
2290
+ ['-736572386776427694074897356960455256508397907579', '-4106376469421816415487320805727264950214313', '736574400416293759865465431760192928844635287762'],
2291
+ ];
2292
+ }
2293
+
2294
+ /**
2295
+ * @dataProvider providerNot
2296
+ */
2297
+ public function testNot(string $number, string $expected) : void
2298
+ {
2299
+ self::assertBigIntegerEquals($expected, BigInteger::of($number)->not());
2300
+ }
2301
+
2302
+ public function providerNot() : array
2303
+ {
2304
+ return [
2305
+ ['-32769', '32768'],
2306
+ ['-32768', '32767'],
2307
+ ['-32767', '32766'],
2308
+ ['-129', '128'],
2309
+ ['-128', '127'],
2310
+ ['-127', '126'],
2311
+ ['-1', '0'],
2312
+ ['0', '-1'],
2313
+ ['1', '-2'],
2314
+ ['126', '-127'],
2315
+ ['127', '-128'],
2316
+ ['128', '-129'],
2317
+ ['32766', '-32767'],
2318
+ ['32767', '-32768'],
2319
+ ['32768', '-32769'],
2320
+ ['-384790918029180298023485788625683230', '384790918029180298023485788625683229'],
2321
+ ['1934938934728983957845827937928492839', '-1934938934728983957845827937928492840'],
2322
+ ['-4839798736875689781936287349837948739479871298187364', '4839798736875689781936287349837948739479871298187363'],
2323
+ ['38797812039284098329810374984757861464098238209830923', '-38797812039284098329810374984757861464098238209830924'],
2324
+ ];
2325
+ }
2326
+
2327
+ /**
2328
+ * @dataProvider providerShiftedLeft
2329
+ *
2330
+ * @param string $a The base number as a string.
2331
+ * @param int $b The distance to shift.
2332
+ * @param string $c The expected shifted result.
2333
+ */
2334
+ public function testShiftedLeft(string $a, int $b, string $c) : void
2335
+ {
2336
+ self::assertBigIntegerEquals($c, BigInteger::of($a)->shiftedLeft($b));
2337
+ }
2338
+
2339
+ /**
2340
+ * @dataProvider providerShiftedLeft
2341
+ *
2342
+ * @param string $a The base number as a string.
2343
+ * @param int $b The distance to shift, negated.
2344
+ * @param string $c The expected shifted result.
2345
+ */
2346
+ public function testShiftedRight(string $a, int $b, string $c) : void
2347
+ {
2348
+ self::assertBigIntegerEquals($c, BigInteger::of($a)->shiftedRight(- $b));
2349
+ }
2350
+
2351
+ public function providerShiftedLeft() : array
2352
+ {
2353
+ return [
2354
+ ['-1', 1, '-2'],
2355
+ ['0', 1, '0'],
2356
+ ['123456789', 1, '246913578'],
2357
+ ['123456789012345678901234567890', 5, '3950617248395061724839506172480'],
2358
+
2359
+ ['-3', -1, '-2'],
2360
+ ['-5', -1, '-3'],
2361
+ ['0', -1, '0'],
2362
+ ['123456789', -1, '61728394'],
2363
+ ['123456789012345678901234567890', -5, '3858024656635802465663580246'],
2364
+
2365
+ ['0', 1234, '0'],
2366
+ ['123456789012345678901234567890123456789', -1234, '0'],
2367
+
2368
+ // positive numbers
2369
+ ['940284045728639319919', -30, '875707758337'],
2370
+ ['42978362369910548649285004217387822572104484', -29, '80053438190204181986460470068059531'],
2371
+ ['459345371944440232668194594123525547022502888486824664', -28, '1711194857748002680645117886824628513390209110'],
2372
+ ['6040754049963507472881320692872216084477635', -27, '45007124915447141773114507592262447'],
2373
+ ['4078667231774103305184642707', -26, '60776877876730312484'],
2374
+ ['49933972074091440160998613689415662078540305149310089516', -25, '1488148333850247864752966573518981399492630515972'],
2375
+ ['7469704937412423665301806569774896261346003606', -24, '445229109371448973733294401751452461561'],
2376
+ ['4991662329264086789092371305806367691268283251684722', -23, '595052519948969696651979840493961297424827009'],
2377
+ ['24261999837317270532438045068264219175859948', -22, '5784511527375524170979987399164252084'],
2378
+ ['30371555400148612343', -21, '14482286167215'],
2379
+ ['5661131843547409961338457445416414214646503036114430', -20, '5398876040980730019892175145546354498526099239'],
2380
+ ['8205785117713792771432053488594', -19, '15651293025424562018264872'],
2381
+ ['121092557102525568761309643138214893231215421503311254716', -18, '461931446466543459935415813973292897152768789304013'],
2382
+ ['176832410305963244194755884422808046154', -17, '1349124224136072114522978854544128'],
2383
+ ['9257459072334599354676845177097713467419426212966300860', -16, '141257615239480580973462603410304465750418490798435'],
2384
+ ['358222782083114778901537224', -15, '10932091738376305508469'],
2385
+ ['3589719402585266626776181409564006983030', -14, '219099084630448402513194666111084410'],
2386
+ ['4053727526539426059356755247362494', -13, '494839785954519782636322662031'],
2387
+ ['725310076963322368834522210259051', -12, '177077655508623625203740773989'],
2388
+ ['15618902589710355419154884565473458', -11, '7626417280132009482009220979235'],
2389
+ ['4176145333272593876621060606107583696', -10, '4078266927024017457637754498151937'],
2390
+ ['36957174148569349375515', -9, '72181980758924510499'],
2391
+ ['72983575681651773692689777', -8, '285092092506452240987069'],
2392
+ ['9789916499422385005848170375683173495755783', -7, '76483722651737382858188831060024792935592'],
2393
+ ['22219967481086668708627972044908677992130264215', -6, '347186991891979198572312063201698093627035378'],
2394
+ ['476504808428399978450599528182547', -5, '14890775263387499326581235255704'],
2395
+ ['806897646899661595924', -4, '50431102931228849745'],
2396
+ ['19227989434278291392821522776905972539189753171235', -3, '2403498679284786424102690347113246567398719146404'],
2397
+ ['145495876920185147465944298588326187', -2, '36373969230046286866486074647081546'],
2398
+ ['43390213276209209707014978611315057', -1, '21695106638104604853507489305657528'],
2399
+ ['107341060399080801706832336473384922229279580', 0, '107341060399080801706832336473384922229279580'],
2400
+ ['4599979410301725512972129610968772187254123116327', 1, '9199958820603451025944259221937544374508246232654'],
2401
+ ['1668450699560464956', 2, '6673802798241859824'],
2402
+ ['97153745662292681364860198', 3, '777229965298341450918881584'],
2403
+ ['3009085333029300076464813411170930572730358705813', 4, '48145365328468801223437014578734889163685739293008'],
2404
+ ['1259873000065121436479893867676', 5, '40315936002083885967356603765632'],
2405
+ ['5095511474364199858927072259281168', 6, '326112734359308790971332624593994752'],
2406
+ ['8881118206295853395928412137856827361', 7, '1136783130405869234678836753645673902208'],
2407
+ ['73610836099012694560370201022735572', 8, '18844374041347249807454771461820306432'],
2408
+ ['7873342832620148736874355104307939702351545648205041367132', 9, '4031151530301516153279669813405665127603991371880981179971584'],
2409
+ ['80476295381045062126801719697', 10, '82407726470190143617844960969728'],
2410
+ ['3897101494489818878437105205', 11, '7981263860715149063039191459840'],
2411
+ ['71689619759395149437011083050942636989790', 12, '293640682534482532093997396176661041110179840'],
2412
+ ['333645680629360116658609620408319342692139569341169', 13, '2733225415715718075667330010384952055334007352042856448'],
2413
+ ['890373515888093126475933575522120914024009528750', 14, '14587879684310517784181695701354429055369372119040000'],
2414
+ ['30946288676751711479181903524629432893', 15, '1014047987359800081749832614695057257037824'],
2415
+ ['8574513284773012626093531873375657960', 16, '561939302630884155463665704853547120066560'],
2416
+ ['69030243610586785879463086990006910709030034224', 17, '9047932090526831198792985737954185800453984645808128'],
2417
+ ['6865607235477540676116751515371066', 18, '1799777743137024422999949709245432725504'],
2418
+ ['5735193503479456072418969854460250', 19, '3006893131552237065296396867055255552000'],
2419
+ ['9048587571607615464851554762153259902641683626953182', 20, '9488131761486026993672183886279616655672406050816059768832'],
2420
+ ['2370160098545184898273', 21, '4970585990984231599783018496'],
2421
+ ['6371742038227378435605172332194796999298927822243', 22, '26725023117905246281972516733613965833347490160545103872'],
2422
+ ['26207519883779202355130662492597335498961566699008934586', 23, '219844610957229287109867916430701949345272990103839940739596288'],
2423
+ ['74820994561612168747902380445044412766494233082859272179', 24, '1255287987094992663312007783640686242576631311185475906949873664'],
2424
+ ['7863511842172307126057945', 25, '263855673389365411744426743562240'],
2425
+ ['90830051704668768299', 26, '6095501586961584536825102336'],
2426
+ ['231276168421338512977415195026', 27, '31041361866057401930727182789066620928'],
2427
+ ['11591917961288582194173295725806158', 28, '3111681783853090908886389181179626990338048'],
2428
+ ['38341121775077207775413588', 29, '20584233014488759408799784166752256'],
2429
+ ['891298514985607971246244019814562069431', 30, '957024493209138036794881606984780018192056582144'],
2430
+
2431
+ // negative numbers
2432
+ ['-1237372339423270864540664117814', -30, '-1152392792909658387807'],
2433
+ ['-35734786450376781153321', -29, '-66561226640599'],
2434
+ ['-350375475884383289232681762242910646883', -28, '-1305250361131069396557963498842'],
2435
+ ['-4617840391045771047614500006075', -27, '-34405592017216764745225'],
2436
+ ['-27995582655724767116836664611604632973', -26, '-417166689868640409660885700757'],
2437
+ ['-88315321329400450504411498573284859753834938505', -25, '-2632001678031696394217356996932174556072'],
2438
+ ['-437674836865187689637228663', -24, '-26087453178476553538'],
2439
+ ['-192317801462512108553659234', -23, '-22926068480314267702'],
2440
+ ['-126204812290953464957001472236330489664', -22, '-30089572022188535918474548396190'],
2441
+ ['-5028144589183389011262798573489176268405', -21, '-2397606176940626626616858755821789'],
2442
+ ['-60642321304451950418527643944555492427721664313816', -20, '-57833024315311384600188869423442356517526307'],
2443
+ ['-5519655948197797131908202', -19, '-10527908226390451683'],
2444
+ ['-441338568999382089736819258485250', -18, '-1683573032376793250033642802'],
2445
+ ['-15197228212774116306143991214042822478217336134849845725', -17, '-115945649816697054337646417343466358018625916556167'],
2446
+ ['-86508083500205763872897394724129182619208043270959408954', -16, '-1320008598330776426283224406801287576587036793074943'],
2447
+ ['-314559273451051294518231893383720551240487085598205396', -15, '-9599587202485696243842526043204362525649630297797'],
2448
+ ['-1773964912051971854901509472944599559', -14, '-108274225589109610284515959042029'],
2449
+ ['-950863346236503075147803', -13, '-116072185819885629291'],
2450
+ ['-123039115193432540987413574511885183658944', -12, '-30038846482771616452005267214815718667'],
2451
+ ['-44855253438053014529473887873121988016001', -11, '-21901979217799323500719671813047845711'],
2452
+ ['-969661032422144957997200094060422207789677054', -10, '-946934601974750935544140716855881062294607'],
2453
+ ['-447489909594763600404330986711528177365046540847822', -9, '-874003729677272657039708958420953471416106525094'],
2454
+ ['-14045183720116080215449840714517462781770864', -8, '-54863998906703438341600940291083838991293'],
2455
+ ['-3299830436298183536285101988500049758', -7, '-25779925283579558877227359285156639'],
2456
+ ['-5019351831439253154367591191464319', -6, '-78427372366238330536993612366630'],
2457
+ ['-38795226574432330534560721103703978442243266604688184102678', -5, '-1212350830451010329205022534490749326320102081396505753209'],
2458
+ ['-550505672867291116049922196115226897669049024412835', -4, '-34406604554205694753120137257201681104315564025803'],
2459
+ ['-4181785333295290828956638533933522764', -3, '-522723166661911353619579816741690346'],
2460
+ ['-58253383391148486554155255025355913', -2, '-14563345847787121638538813756338979'],
2461
+ ['-78072807980226950108001170178', -1, '-39036403990113475054000585089'],
2462
+ ['-2739739627183043192544967754527367420831889358990397380', 0, '-2739739627183043192544967754527367420831889358990397380'],
2463
+ ['-6802649114840946885444462648295302', 1, '-13605298229681893770888925296590604'],
2464
+ ['-7711910168688261765675862240931391560', 2, '-30847640674753047062703448963725566240'],
2465
+ ['-78150769840135288210477422', 3, '-625206158721082305683819376'],
2466
+ ['-48416578493609461712161279293681', 4, '-774665255897751387394580468698896'],
2467
+ ['-963028038608902450630794252350953199258094761611', 5, '-30816897235484878420185416075230502376259032371552'],
2468
+ ['-1425323867965759220038394395246107977999821', 6, '-91220727549808590082457241295750910591988544'],
2469
+ ['-224892690751744072093860005492753257', 7, '-28786264416223241228014080703072416896'],
2470
+ ['-1342157478927956315396', 8, '-343592314605556816741376'],
2471
+ ['-5671022663122810048459617618469813436271952017702608325', 9, '-2903563603518878744811324220656544479371239433063735462400'],
2472
+ ['-46213908327252308063252283743615825103944376575531142630707', 10, '-47323042127106363456770338553462604906439041613343890053843968'],
2473
+ ['-1443335666407076242843975171397153215688292050', 11, '-2955951444801692145344461151021369785729622118400'],
2474
+ ['-387072173209607249289609530361384', 12, '-1585447621466551293090240636360228864'],
2475
+ ['-30736899295720315680717', 13, '-251796679030540826056433664'],
2476
+ ['-66511372620325071045088', 14, '-1089722329011405964002721792'],
2477
+ ['-16831212979074223740', 15, '-551525186898304163512320'],
2478
+ ['-2867585884213675945325235733', 16, '-187930108507827466752834648997888'],
2479
+ ['-847247216997347939369738040936389314911814493500001189', 17, '-111050387226276389109070304501614420284121349292032155844608'],
2480
+ ['-4089932815136020694242664', 18, '-1072151347891017008871548911616'],
2481
+ ['-9681942860006157944589342578524581427227754117530', 19, '-5076126458186908536452857241809495747318384750771568640'],
2482
+ ['-3145980648451124121924460760091441029335360706964602774838', 20, '-3298799804430285927271063365973642868776355188666115319228530688'],
2483
+ ['-19270031819736683617335308049302261495063213645341141', 21, '-40412185770824425521461975946210336298894808622754464530432'],
2484
+ ['-5854557994845898152102048100066000953660980958739', 22, '-24555796016014130002954228754299228063944067079162822656'],
2485
+ ['-537126409576534616665629846223812575792202734591383198404', 23, '-4505742896384994897638235853071843963791078197015153829197381632'],
2486
+ ['-207462793032740058202867058129136', 24, '-3480648090673575028322072453517070565376'],
2487
+ ['-8403828351720334896765545419908214', 25, '-281985686967472060310746513735221612904448'],
2488
+ ['-1998653332269111002668466897443760635558181763512849966686', 26, '-134127354658394581678981782109055280140227584054864010666735304704'],
2489
+ ['-939931592701732496693966621537', 27, '-126155482847847917370031711250532007936'],
2490
+ ['-40818093627295495469409741857838451891730234', 28, '-10957023575893760373076938106451152007890667992776704'],
2491
+ ['-690188350197447300310251', 29, '-370542049022278912189502337318912'],
2492
+ ['-21087241977645058543789195285783471320391', 30, '-22642253664205972385394994417649345764608320733184'],
2493
+ ];
2494
+ }
2495
+
2496
+ /**
2497
+ * @dataProvider providerGetBitLength
2498
+ *
2499
+ * @param string $number The number to test.
2500
+ * @param int $bitLength The expected bit length.
2501
+ */
2502
+ public function testGetBitLength(string $number, int $bitLength) : void
2503
+ {
2504
+ self::assertSame($bitLength, BigInteger::of($number)->getBitLength());
2505
+ }
2506
+
2507
+ public function providerGetBitLength() : array
2508
+ {
2509
+ return [
2510
+ ['-10141204801825835211973625643009', 104],
2511
+ ['-10141204801825835211973625643008', 103],
2512
+ ['-5070602400912917605986812821505', 103],
2513
+ ['-5070602400912917605986812821504', 102],
2514
+ ['-2535301200456458802993406410753', 102],
2515
+ ['-2535301200456458802993406410752', 101],
2516
+ ['-1267650600228229401496703205377', 101],
2517
+ ['-1267650600228229401496703205376', 100],
2518
+ ['-633825300114114700748351602689', 100],
2519
+ ['-633825300114114700748351602688', 99],
2520
+
2521
+ ['-18446744073709551617', 65],
2522
+ ['-18446744073709551616', 64],
2523
+ ['-9223372036854775809', 64],
2524
+ ['-9223372036854775808', 63],
2525
+
2526
+ ['-4294967297', 33],
2527
+ ['-4294967296', 32],
2528
+ ['-2147483649', 32],
2529
+ ['-2147483648', 31],
2530
+
2531
+ ['-9', 4],
2532
+ ['-8', 3],
2533
+ ['-7', 3],
2534
+ ['-6', 3],
2535
+ ['-5', 3],
2536
+ ['-4', 2],
2537
+ ['-3', 2],
2538
+ ['-2', 1],
2539
+ ['-1', 0],
2540
+ ['0', 0],
2541
+ ['1', 1],
2542
+ ['2', 2],
2543
+ ['3', 2],
2544
+ ['4', 3],
2545
+ ['5', 3],
2546
+ ['6', 3],
2547
+ ['7', 3],
2548
+ ['8', 4],
2549
+
2550
+ ['2147483647', 31],
2551
+ ['2147483648', 32],
2552
+ ['4294967295', 32],
2553
+ ['4294967296', 33],
2554
+
2555
+ ['9223372036854775807', 63],
2556
+ ['9223372036854775808', 64],
2557
+ ['18446744073709551615', 64],
2558
+ ['18446744073709551616', 65],
2559
+
2560
+ ['633825300114114700748351602687', 99],
2561
+ ['633825300114114700748351602688', 100],
2562
+ ['1267650600228229401496703205375', 100],
2563
+ ['1267650600228229401496703205376', 101],
2564
+ ['2535301200456458802993406410751', 101],
2565
+ ['2535301200456458802993406410752', 102],
2566
+ ['5070602400912917605986812821503', 102],
2567
+ ['5070602400912917605986812821504', 103],
2568
+ ['10141204801825835211973625643007', 103],
2569
+ ['10141204801825835211973625643008', 104],
2570
+ ];
2571
+ }
2572
+
2573
+ /**
2574
+ * @dataProvider providerGetLowestSetBit
2575
+ *
2576
+ * @param string $number The number to test.
2577
+ * @param int $lowestSetBit The expected lowest set bit.
2578
+ */
2579
+ public function testGetLowestSetBit(string $number, int $lowestSetBit) : void
2580
+ {
2581
+ self::assertSame($lowestSetBit, BigInteger::of($number)->getLowestSetBit());
2582
+ }
2583
+
2584
+ public function providerGetLowestSetBit() : array
2585
+ {
2586
+ return [
2587
+ ['-10', 1],
2588
+ ['-9', 0],
2589
+ ['-8', 3],
2590
+ ['-7', 0],
2591
+ ['-6', 1],
2592
+ ['-5', 0],
2593
+ ['-4', 2],
2594
+ ['-3', 0],
2595
+ ['-2', 1],
2596
+ ['-1', 0],
2597
+ ['0', -1],
2598
+ ['1', 0],
2599
+ ['2', 1],
2600
+ ['3', 0],
2601
+ ['4', 2],
2602
+ ['5', 0],
2603
+ ['6', 1],
2604
+ ['7', 0],
2605
+ ['8', 3],
2606
+ ['9', 0],
2607
+ ['10', 1],
2608
+
2609
+ ['-1328165573307087716352', 67],
2610
+ ['-1254378597012249509888', 66],
2611
+ ['-1291272085159668613120', 65],
2612
+
2613
+ ['1291272085159668613120', 65],
2614
+ ['1254378597012249509888', 66],
2615
+ ['1328165573307087716352', 67],
2616
+ ];
2617
+ }
2618
+
2619
+ /**
2620
+ * @dataProvider providerIsOdd
2621
+ *
2622
+ * @param string $number The number to test.
2623
+ * @param bool $isOdd Whether the number is even.
2624
+ */
2625
+ public function testIsEven(string $number, bool $isOdd) : void
2626
+ {
2627
+ self::assertSame(! $isOdd, BigInteger::of($number)->isEven());
2628
+ }
2629
+
2630
+ /**
2631
+ * @dataProvider providerIsOdd
2632
+ *
2633
+ * @param string $number The number to test.
2634
+ * @param bool $isOdd Whether the number is even.
2635
+ */
2636
+ public function testIsOdd(string $number, bool $isOdd) : void
2637
+ {
2638
+ self::assertSame($isOdd, BigInteger::of($number)->isOdd());
2639
+ }
2640
+
2641
+ public function providerIsOdd() : \Generator
2642
+ {
2643
+ $tests = [
2644
+ ['123456789012345678900', false],
2645
+ ['123456789012345678901', true],
2646
+ ['123456789012345678902', false],
2647
+ ['123456789012345678903', true],
2648
+ ['123456789012345678904', false],
2649
+ ['123456789012345678905', true],
2650
+ ['123456789012345678906', false],
2651
+ ['123456789012345678907', true],
2652
+ ['123456789012345678908', false],
2653
+ ['123456789012345678909', true],
2654
+ ];
2655
+
2656
+ foreach ($tests as [$number, $isOdd]) {
2657
+ yield [$number, $isOdd];
2658
+ yield ['-' . $number, $isOdd];
2659
+ }
2660
+ }
2661
+
2662
+ /**
2663
+ * @dataProvider providerTestBit
2664
+ *
2665
+ * @param BigInteger $number The number in base 2.
2666
+ * @param int $n The bit to test.
2667
+ * @param bool $expected The expected result.
2668
+ */
2669
+ public function testTestBit(BigInteger $number, int $n, bool $expected) : void
2670
+ {
2671
+ self::assertSame($expected, $number->testBit($n));
2672
+ }
2673
+
2674
+ public function providerTestBit() : \Generator
2675
+ {
2676
+ $base2BitsSetTests = [
2677
+ ['0', []],
2678
+ ['1', [0]],
2679
+ ['10', [1]],
2680
+ ['11', [0, 1]],
2681
+ ['100', [2]],
2682
+ ['101', [0, 2]],
2683
+ ['110', [1, 2]],
2684
+ ['111', [0, 1, 2]],
2685
+ ['100000010000000001000000000111', [0, 1, 2, 12, 22, 29]],
2686
+ ['101000010000000000001000100001000001000000100000100000000100000000001', [0, 11, 20, 26, 33, 39, 44, 48, 61, 66, 68]],
2687
+ ];
2688
+
2689
+ foreach ($base2BitsSetTests as [$number, $bitsSet]) {
2690
+ $number = BigInteger::fromBase($number, 2);
2691
+
2692
+ // test up to 5 bits after the last bit set
2693
+ $testBitCount = ($bitsSet[count($bitsSet) - 1] ?? 0) + 5;
2694
+
2695
+ for ($n = 0; $n < $testBitCount; $n++) {
2696
+ $isSet = in_array($n, $bitsSet);
2697
+ yield [$number, $n, $isSet];
2698
+ }
2699
+ }
2700
+
2701
+ $base10BitsUnsetTests = [
2702
+ [-1, []],
2703
+ [-2, [0]],
2704
+ [-3, [1]],
2705
+ [-4, [0, 1]],
2706
+ [-5, [2]],
2707
+ [-6, [0, 2]],
2708
+ [-7, [1, 2]],
2709
+ [-8, [0, 1, 2]],
2710
+ [-9, [3]],
2711
+ ['-1181745669222511412225', [10, 20, 30, 40, 50, 60, 70]],
2712
+ ];
2713
+
2714
+ foreach ($base10BitsUnsetTests as [$number, $bitsUnset]) {
2715
+ $number = BigInteger::of($number);
2716
+
2717
+ // test up to 5 bits after the last bit set
2718
+ $testBitCount = ($bitsUnset[count($bitsUnset) - 1] ?? 0) + 5;
2719
+
2720
+ for ($n = 0; $n < $testBitCount; $n++) {
2721
+ $isSet = ! in_array($n, $bitsUnset);
2722
+ yield [$number, $n, $isSet];
2723
+ }
2724
+ }
2725
+ }
2726
+
2727
+ public function testTestNegativeBitThrowsException() : void
2728
+ {
2729
+ $number = BigInteger::one();
2730
+
2731
+ $this->expectException(\InvalidArgumentException::class);
2732
+ $number->testBit(-1);
2733
+ }
2734
+
2735
+ /**
2736
+ * @dataProvider providerModInverse
2737
+ */
2738
+ public function testModInverse(string $x, string $m, string $expectedResult) : void
2739
+ {
2740
+ $x = BigInteger::of($x);
2741
+ $m = BigInteger::of($m);
2742
+
2743
+ self::assertSame($expectedResult, (string) $x->modInverse($m));
2744
+ }
2745
+
2746
+ public function providerModInverse() : array
2747
+ {
2748
+ return [
2749
+ ['1', '1', '0'],
2750
+ ['1234567890', '19', '11'],
2751
+ ['-1234567890', '19', '8'],
2752
+ ['1234567890', '1000000001', '189108911'],
2753
+ ['19', '1234567890', '519818059'],
2754
+ ['1000000001', '1234567890', '1001100101'],
2755
+ ['12345', '12346', '12345'],
2756
+ ['1234567890', '137', '42'],
2757
+ ['137', '1234567890', '856087223'],
2758
+ ['1234567890123456', '137', '77'],
2759
+ ['137', '1234567890123456', '540686667207353'],
2760
+ ['590295810358705600000', '137', '128'],
2761
+ ['18506109802501380149367860917982816833935316655779336003703143134999470532428', '115792089237316195423570985008687907853269984665640564039457584007908834671663', '95929095851002583825372225918533539673793386278360575987103577151530201707061'],
2762
+ ['-18506109802501380149367860917982816833935316655779336003703143134999470532428', '115792089237316195423570985008687907853269984665640564039457584007908834671663', '19862993386313611598198759090154368179476598387279988052354006856378632964602'],
2763
+ ];
2764
+ }
2765
+
2766
+ /**
2767
+ * @dataProvider providerModInverseThrows
2768
+ */
2769
+ public function testModInverseThrows(string $x, string $m, string $expectedException) : void
2770
+ {
2771
+ $x = BigInteger::of($x);
2772
+ $m = BigInteger::of($m);
2773
+
2774
+ $this->expectException($expectedException);
2775
+ $x->modInverse($m);
2776
+ }
2777
+
2778
+ public function providerModInverseThrows() : array
2779
+ {
2780
+ return [
2781
+ ['0', '0', DivisionByZeroException::class],
2782
+ ['1', '0', DivisionByZeroException::class],
2783
+ ['-1234567890', '-19', NegativeNumberException::class],
2784
+ ['0', '1000000001', MathException::class],
2785
+ ['2', '4', MathException::class],
2786
+ ['99', '9', MathException::class],
2787
+ ['19', '1000000001', MathException::class],
2788
+ ['123456789012345678901234567890', '123456789012345678901234567899', MathException::class],
2789
+ ];
2790
+ }
2791
+
2792
+ /**
2793
+ * @dataProvider providerCompareTo
2794
+ *
2795
+ * @param string $a The base number as a string.
2796
+ * @param string $b The number to compare to as a string.
2797
+ * @param int $c The expected comparison result.
2798
+ */
2799
+ public function testCompareTo(string $a, string $b, int $c) : void
2800
+ {
2801
+ self::assertSame($c, BigInteger::of($a)->compareTo($b));
2802
+ }
2803
+
2804
+ /**
2805
+ * @dataProvider providerCompareTo
2806
+ *
2807
+ * @param string $a The base number as a string.
2808
+ * @param string $b The number to compare to as a string.
2809
+ * @param int $c The comparison result.
2810
+ */
2811
+ public function testIsEqualTo(string $a, string $b, int $c) : void
2812
+ {
2813
+ self::assertSame($c === 0, BigInteger::of($a)->isEqualTo($b));
2814
+ }
2815
+
2816
+ /**
2817
+ * @dataProvider providerCompareTo
2818
+ *
2819
+ * @param string $a The base number as a string.
2820
+ * @param string $b The number to compare to as a string.
2821
+ * @param int $c The comparison result.
2822
+ */
2823
+ public function testIsLessThan(string $a, string $b, int $c) : void
2824
+ {
2825
+ self::assertSame($c < 0, BigInteger::of($a)->isLessThan($b));
2826
+ }
2827
+
2828
+ /**
2829
+ * @dataProvider providerCompareTo
2830
+ *
2831
+ * @param string $a The base number as a string.
2832
+ * @param string $b The number to compare to as a string.
2833
+ * @param int $c The comparison result.
2834
+ */
2835
+ public function testIsLessThanOrEqualTo(string $a, string $b, int $c) : void
2836
+ {
2837
+ self::assertSame($c <= 0, BigInteger::of($a)->isLessThanOrEqualTo($b));
2838
+ }
2839
+
2840
+ /**
2841
+ * @dataProvider providerCompareTo
2842
+ *
2843
+ * @param string $a The base number as a string.
2844
+ * @param string $b The number to compare to as a string.
2845
+ * @param int $c The comparison result.
2846
+ */
2847
+ public function testIsGreaterThan(string $a, string $b, int $c) : void
2848
+ {
2849
+ self::assertSame($c > 0, BigInteger::of($a)->isGreaterThan($b));
2850
+ }
2851
+
2852
+ /**
2853
+ * @dataProvider providerCompareTo
2854
+ *
2855
+ * @param string $a The base number as a string.
2856
+ * @param string $b The number to compare to as a string.
2857
+ * @param int $c The comparison result.
2858
+ */
2859
+ public function testIsGreaterThanOrEqualTo(string $a, string $b, int $c) : void
2860
+ {
2861
+ self::assertSame($c >= 0, BigInteger::of($a)->isGreaterThanOrEqualTo($b));
2862
+ }
2863
+
2864
+ public function providerCompareTo() : array
2865
+ {
2866
+ return [
2867
+ ['123', '123', 0],
2868
+ ['123', '456', -1],
2869
+ ['456', '123', 1],
2870
+ ['456', '456', 0],
2871
+
2872
+ ['-123', '-123', 0],
2873
+ ['-123', '456', -1],
2874
+ [ '456', '-123', 1],
2875
+ [ '456', '456', 0],
2876
+
2877
+ [ '123', '123', 0],
2878
+ [ '123', '-456', 1],
2879
+ ['-456', '123', -1],
2880
+ ['-456', '456', -1],
2881
+
2882
+ ['-123', '-123', 0],
2883
+ ['-123', '-456', 1],
2884
+ ['-456', '-123', -1],
2885
+ ['-456', '-456', 0],
2886
+
2887
+ [ '9999999999999999999999999', '11111111111111111111111111111111111111111111', -1],
2888
+ [ '9999999999999999999999999', '-11111111111111111111111111111111111111111111', 1],
2889
+ ['-9999999999999999999999999', '11111111111111111111111111111111111111111111', -1],
2890
+ ['-9999999999999999999999999', '-11111111111111111111111111111111111111111111', 1],
2891
+
2892
+ [ '11111111111111111111111111111111111111111111', '9999999999999999999999999', 1],
2893
+ [ '11111111111111111111111111111111111111111111', '-9999999999999999999999999', 1],
2894
+ ['-11111111111111111111111111111111111111111111', '9999999999999999999999999', -1],
2895
+ ['-11111111111111111111111111111111111111111111','-9999999999999999999999999', -1],
2896
+
2897
+ ['123', '123.000000000000000000000000000000000000000000000000000000001', -1],
2898
+ ['123', '123.000000000000000000000000000000000000000000000000000000000', 0],
2899
+ ['123', '122.999999999999999999999999999999999999999999999999999999999', 1],
2900
+
2901
+ ['123', '246/2', 0],
2902
+ ['123', '245/2', 1],
2903
+ ['123', '247/2', -1],
2904
+ ];
2905
+ }
2906
+
2907
+ /**
2908
+ * @dataProvider providerSign
2909
+ *
2910
+ * @param int|string $number The number to test.
2911
+ * @param int $sign The sign of the number.
2912
+ */
2913
+ public function testGetSign($number, int $sign) : void
2914
+ {
2915
+ self::assertSame($sign, BigInteger::of($number)->getSign());
2916
+ }
2917
+
2918
+ /**
2919
+ * @dataProvider providerSign
2920
+ *
2921
+ * @param int|string $number The number to test.
2922
+ * @param int $sign The sign of the number.
2923
+ */
2924
+ public function testIsZero($number, int $sign) : void
2925
+ {
2926
+ self::assertSame($sign === 0, BigInteger::of($number)->isZero());
2927
+ }
2928
+
2929
+ /**
2930
+ * @dataProvider providerSign
2931
+ *
2932
+ * @param int|string $number The number to test.
2933
+ * @param int $sign The sign of the number.
2934
+ */
2935
+ public function testIsNegative($number, int $sign) : void
2936
+ {
2937
+ self::assertSame($sign < 0, BigInteger::of($number)->isNegative());
2938
+ }
2939
+
2940
+ /**
2941
+ * @dataProvider providerSign
2942
+ *
2943
+ * @param int|string $number The number to test.
2944
+ * @param int $sign The sign of the number.
2945
+ */
2946
+ public function testIsNegativeOrZero($number, int $sign) : void
2947
+ {
2948
+ self::assertSame($sign <= 0, BigInteger::of($number)->isNegativeOrZero());
2949
+ }
2950
+
2951
+ /**
2952
+ * @dataProvider providerSign
2953
+ *
2954
+ * @param int|string $number The number to test.
2955
+ * @param int $sign The sign of the number.
2956
+ */
2957
+ public function testIsPositive($number, int $sign) : void
2958
+ {
2959
+ self::assertSame($sign > 0, BigInteger::of($number)->isPositive());
2960
+ }
2961
+
2962
+ /**
2963
+ * @dataProvider providerSign
2964
+ *
2965
+ * @param int|string $number The number to test.
2966
+ * @param int $sign The sign of the number.
2967
+ */
2968
+ public function testIsPositiveOrZero($number, int $sign) : void
2969
+ {
2970
+ self::assertSame($sign >= 0, BigInteger::of($number)->isPositiveOrZero());
2971
+ }
2972
+
2973
+ public function providerSign() : array
2974
+ {
2975
+ return [
2976
+ [ 0, 0],
2977
+ [-0, 0],
2978
+ [ 1, 1],
2979
+ [-1, -1],
2980
+
2981
+ [PHP_INT_MAX, 1],
2982
+ [PHP_INT_MIN, -1],
2983
+
2984
+ [ '1000000000000000000000000000000000000000000000000000000000000000000000000000000000', 1],
2985
+ ['-1000000000000000000000000000000000000000000000000000000000000000000000000000000000', -1]
2986
+ ];
2987
+ }
2988
+
2989
+ /**
2990
+ * @dataProvider providerToScale
2991
+ *
2992
+ * @param string $number
2993
+ * @param int $scale
2994
+ * @param string $expected
2995
+ */
2996
+ public function testToScale(string $number, int $scale, string $expected) : void
2997
+ {
2998
+ self::assertBigDecimalEquals($expected, BigInteger::of($number)->toScale($scale));
2999
+ }
3000
+
3001
+ public function providerToScale() : array
3002
+ {
3003
+ return [
3004
+ ['12345678901234567890123456789', 0, '12345678901234567890123456789'],
3005
+ ['12345678901234567890123456789', 1, '12345678901234567890123456789.0'],
3006
+ ['12345678901234567890123456789', 2, '12345678901234567890123456789.00'],
3007
+ ];
3008
+ }
3009
+
3010
+ /**
3011
+ * @dataProvider providerToInt
3012
+ */
3013
+ public function testToInt(int $number) : void
3014
+ {
3015
+ self::assertSame($number, BigInteger::of((string) $number)->toInt());
3016
+ }
3017
+
3018
+ public function providerToInt() : array
3019
+ {
3020
+ return [
3021
+ [PHP_INT_MIN],
3022
+ [-123456789],
3023
+ [-1],
3024
+ [0],
3025
+ [1],
3026
+ [123456789],
3027
+ [PHP_INT_MAX]
3028
+ ];
3029
+ }
3030
+
3031
+ public function testToIntNegativeOverflowThrowsException() : void
3032
+ {
3033
+ $this->expectException(IntegerOverflowException::class);
3034
+ BigInteger::of(PHP_INT_MIN)->minus(1)->toInt();
3035
+ }
3036
+
3037
+ public function testToIntPositiveOverflowThrowsException() : void
3038
+ {
3039
+ $this->expectException(IntegerOverflowException::class);
3040
+ BigInteger::of(PHP_INT_MAX)->plus(1)->toInt();
3041
+ }
3042
+
3043
+ /**
3044
+ * @dataProvider providerToFloat
3045
+ *
3046
+ * @param string $value The big integer value.
3047
+ * @param float $float The expected float value.
3048
+ */
3049
+ public function testToFloat(string $value, float $float) : void
3050
+ {
3051
+ self::assertSame($float, BigInteger::of($value)->toFloat());
3052
+ }
3053
+
3054
+ public function providerToFloat() : array
3055
+ {
3056
+ return [
3057
+ ['0', 0.0],
3058
+ ['1', 1.0],
3059
+ ['-1', -1.0],
3060
+ ['100000000000000000000000000000000000000000000000000', 1e50],
3061
+ ['-100000000000000000000000000000000000000000000000000', -1e50],
3062
+ ['1e3000', INF],
3063
+ ['-1e3000', -INF],
3064
+ ];
3065
+ }
3066
+
3067
+ /**
3068
+ * @dataProvider providerToBase
3069
+ *
3070
+ * @param string $number The number to convert, in base 10.
3071
+ * @param int $base The base to convert the number to.
3072
+ * @param string $expected The expected result.
3073
+ */
3074
+ public function testToBase(string $number, int $base, string $expected) : void
3075
+ {
3076
+ self::assertSame($expected, BigInteger::of($number)->toBase($base));
3077
+ }
3078
+
3079
+ public function providerToBase() : \Generator
3080
+ {
3081
+ $tests = [
3082
+ ['640998479760579495168036691627608949', 36, '110011001100110011001111'],
3083
+ ['335582856048758779730579523833856636', 35, '110011001100110011001111'],
3084
+ ['172426711023004493064981145981549295', 34, '110011001100110011001111'],
3085
+ ['86853227285668653965326574185738990', 33, '110011001100110011001111'],
3086
+ ['42836489934972583913564073319498785', 32, '110011001100110011001111'],
3087
+ ['20658924711984480538771889603666144', 31, '110011001100110011001111'],
3088
+ ['9728140488839986222205212599027931', 30, '110011001100110011001111'],
3089
+ ['4465579470019956787945275674107410', 29, '110011001100110011001111'],
3090
+ ['1994689924537781753408144504465645', 28, '110011001100110011001111'],
3091
+ ['865289950909412968716094193925700', 27, '110011001100110011001111'],
3092
+ ['363729369583879309352831568000039', 26, '110011001100110011001111'],
3093
+ ['147793267388865354156500488297526', 25, '110011001100110011001111'],
3094
+ ['57888012016107577099138793486425', 24, '110011001100110011001111'],
3095
+ ['21788392294523974761749372677800', 23, '110011001100110011001111'],
3096
+ ['7852874701996329566765721637715', 22, '110011001100110011001111'],
3097
+ ['2699289081943123258094476428634', 21, '110011001100110011001111'],
3098
+ ['880809345058406615041344008421', 20, '110011001100110011001111'],
3099
+ ['271401690926468032718781859340', 19, '110011001100110011001111'],
3100
+ ['78478889737009209699633503455', 18, '110011001100110011001111'],
3101
+ ['21142384915931646646976872830', 17, '110011001100110011001111'],
3102
+ ['5261325448418072742917574929', 16, '110011001100110011001111'],
3103
+ ['1197116069565850925807253616', 15, '110011001100110011001111'],
3104
+ ['245991074299834917455374155', 14, '110011001100110011001111'],
3105
+ ['44967318722190498361960610', 13, '110011001100110011001111'],
3106
+ ['7177144825886069940574045', 12, '110011001100110011001111'],
3107
+ ['976899716207148313491924', 11, '110011001100110011001111'],
3108
+ ['110011001100110011001111', 10, '110011001100110011001111'],
3109
+ ['9849210196991880028870', 9, '110011001100110011001111'],
3110
+ ['664244955832213832265', 8, '110011001100110011001111'],
3111
+ ['31291601125492514360', 7, '110011001100110011001111'],
3112
+ ['922063395565287619', 6, '110011001100110011001111'],
3113
+ ['14328039609468906', 5, '110011001100110011001111'],
3114
+ ['88305875046485', 4, '110011001100110011001111'],
3115
+ ['127093291420', 3, '110011001100110011001111'],
3116
+ ['13421775', 2, '110011001100110011001111'],
3117
+
3118
+ ['106300512100105327644605138221229898724869759421181854980', 36, 'zyxwvutsrqponmlkjihgfedcba9876543210'],
3119
+ ['1101553773143634726491620528194292510495517905608180485', 35, 'yxwvutsrqponmlkjihgfedcba9876543210'],
3120
+ ['11745843093701610854378775891116314824081102660800418', 34, 'xwvutsrqponmlkjihgfedcba9876543210'],
3121
+ ['128983956064237823710866404905431464703849549412368', 33, 'wvutsrqponmlkjihgfedcba9876543210'],
3122
+ ['1459980823972598128486511383358617792788444579872', 32, 'vutsrqponmlkjihgfedcba9876543210'],
3123
+ ['17050208381689099029767742314582582184093573615', 31, 'utsrqponmlkjihgfedcba9876543210'],
3124
+ ['205646315052919334126040428061831153388822830', 30, 'tsrqponmlkjihgfedcba9876543210'],
3125
+ ['2564411043271974895869785066497940850811934', 29, 'srqponmlkjihgfedcba9876543210'],
3126
+ ['33100056003358651440264672384704297711484', 28, 'rqponmlkjihgfedcba9876543210'],
3127
+ ['442770531899482980347734468443677777577', 27, 'qponmlkjihgfedcba9876543210'],
3128
+ ['6146269788878825859099399609538763450', 26, 'ponmlkjihgfedcba9876543210'],
3129
+ ['88663644327703473714387251271141900', 25, 'onmlkjihgfedcba9876543210'],
3130
+ ['1331214537196502869015340298036888', 24, 'nmlkjihgfedcba9876543210'],
3131
+ ['20837326537038308910317109288851', 23, 'mlkjihgfedcba9876543210'],
3132
+ ['340653664490377789692799452102', 22, 'lkjihgfedcba9876543210'],
3133
+ ['5827980550840017565077671610', 21, 'kjihgfedcba9876543210'],
3134
+ ['104567135734072022160664820', 20, 'jihgfedcba9876543210'],
3135
+ ['1972313422155189164466189', 19, 'ihgfedcba9876543210'],
3136
+ ['39210261334551566857170', 18, 'hgfedcba9876543210'],
3137
+ ['824008854613343261192', 17, 'gfedcba9876543210'],
3138
+ ['18364758544493064720', 16, 'fedcba9876543210'],
3139
+ ['435659737878916215', 15, 'edcba9876543210'],
3140
+ ['11046255305880158', 14, 'dcba9876543210'],
3141
+ ['300771807240918', 13, 'cba9876543210'],
3142
+ ['8842413667692', 12, 'ba9876543210'],
3143
+ ['282458553905', 11, 'a9876543210'],
3144
+ ['9876543210', 10, '9876543210'],
3145
+ ['381367044', 9, '876543210'],
3146
+ ['16434824', 8, '76543210'],
3147
+ ['800667', 7, '6543210'],
3148
+ ['44790', 6, '543210'],
3149
+ ['2930', 5, '43210'],
3150
+ ['228', 4, '3210'],
3151
+ ['21', 3, '210'],
3152
+ ['2', 2, '10'],
3153
+
3154
+ ['1', 2, '1'],
3155
+ ['0', 2, '0'],
3156
+
3157
+ ['1', 8, '1'],
3158
+ ['0', 8, '0'],
3159
+ ];
3160
+
3161
+ foreach ($tests as [$number, $base, $expected]) {
3162
+ yield [$number, $base, $expected];
3163
+
3164
+ if ($number[0] !== '0') {
3165
+ yield ['-' . $number, $base, '-' . $expected];
3166
+ }
3167
+ }
3168
+ }
3169
+
3170
+ /**
3171
+ * @dataProvider providerToInvalidBaseThrowsException
3172
+ */
3173
+ public function testToInvalidBaseThrowsException(int $base) : void
3174
+ {
3175
+ $this->expectException(\InvalidArgumentException::class);
3176
+ BigInteger::of(0)->toBase($base);
3177
+ }
3178
+
3179
+ public function providerToInvalidBaseThrowsException() : array
3180
+ {
3181
+ return [
3182
+ [-2],
3183
+ [-1],
3184
+ [0],
3185
+ [1],
3186
+ [37]
3187
+ ];
3188
+ }
3189
+
3190
+ /**
3191
+ * @dataProvider providerFromArbitraryBase
3192
+ */
3193
+ public function testFromArbitraryBase(string $base10, string $alphabet, string $baseN) : void
3194
+ {
3195
+ $number = BigInteger::fromArbitraryBase($baseN, $alphabet);
3196
+
3197
+ self::assertBigIntegerEquals($base10, $number);
3198
+ }
3199
+
3200
+ public function providerFromArbitraryBase() : \Generator
3201
+ {
3202
+ foreach ($this->providerArbitraryBase() as [$base10, $alphabet, $baseN]) {
3203
+ yield [$base10, $alphabet, $baseN];
3204
+
3205
+ // test with a number of leading "zeros"
3206
+ yield [$base10, $alphabet, $alphabet[0] . $baseN];
3207
+ yield [$base10, $alphabet, $alphabet[0] . $alphabet[0] . $baseN];
3208
+ }
3209
+ }
3210
+
3211
+ /**
3212
+ * @dataProvider providerArbitraryBase
3213
+ */
3214
+ public function testToArbitraryBase(string $base10, string $alphabet, string $baseN) : void
3215
+ {
3216
+ $base10 = BigInteger::of($base10);
3217
+ $actual = $base10->toArbitraryBase($alphabet);
3218
+
3219
+ self::assertSame($baseN, $actual);
3220
+ }
3221
+
3222
+ public function providerArbitraryBase() : array
3223
+ {
3224
+ $base7 = '0123456';
3225
+ $base8 = '01234567';
3226
+ $base9 = '012345678';
3227
+ $base10 = '0123456789';
3228
+ $base11 = '0123456789A';
3229
+ $base12 = '0123456789AB';
3230
+ $base13 = '0123456789ABC';
3231
+ $base14 = '0123456789ABCD';
3232
+ $base15 = '0123456789ABCDE';
3233
+ $base16 = '0123456789ABCDEF';
3234
+ $base17 = '0123456789ABCDEFG';
3235
+ $base64 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/';
3236
+ $base72 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~_!$()+,;@';
3237
+ $base85 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#';
3238
+ $base95 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~_!$()+,;@.:=^*?&<>[]{}%#|`/\ "\'-';
3239
+
3240
+ $base62LowerUpper = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
3241
+ $base62UpperLower = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
3242
+
3243
+ return [
3244
+ ['0', 'XY', 'X'],
3245
+ ['1', 'XY', 'Y'],
3246
+ ['2', 'XY', 'YX'],
3247
+ ['3', 'XY', 'YY'],
3248
+ ['4', 'XY', 'YXX'],
3249
+
3250
+ ['1234567890', '9876543210', '8765432109'],
3251
+ ['9876543210', '1234567890', '0987654321'],
3252
+
3253
+ ['98719827932647929837981791821991234', '01234567', '460150331736165026742535432255203706502'],
3254
+ ['98719827932647929837981791821991234', 'ABCDEFGH', 'EGABFADDBHDGBGFACGHECFDFEDCCFFCADHAGFAC'],
3255
+
3256
+ ['994495526373444232246567036253784322009', $base7, '12202520340634022241654466246440466210615152466'],
3257
+ ['994495526373444232246567036253784322009', $base8, '13541315742261267512021577112421152053227731'],
3258
+ ['994495526373444232246567036253784322009', $base9, '66488066070032874134652704428716607733277'],
3259
+ ['994495526373444232246567036253784322009', $base10, '994495526373444232246567036253784322009'],
3260
+ ['994495526373444232246567036253784322009', $base11, '2A1978399765A213135A156506809522356825'],
3261
+ ['994495526373444232246567036253784322009', $base12, '14A05B751367AA17A09769472516764A47821'],
3262
+ ['994495526373444232246567036253784322009', $base13, '103A050CB893910A25357BB9C395A51C0814'],
3263
+ ['994495526373444232246567036253784322009', $base14, '10D925D22C52737225B8D5644D989CD666D'],
3264
+ ['994495526373444232246567036253784322009', $base15, '180B5C6CC477E8D58EAC276D06C5127124'],
3265
+ ['994495526373444232246567036253784322009', $base16, '2EC2CDF12C56F4A08DFC9511350AD2FD9'],
3266
+ ['994495526373444232246567036253784322009', $base17, '7266E944CF4A3786D0G7661356FG769G'],
3267
+
3268
+ ['994495526373444232246567036253784322009', $base62LowerUpper, 'mLMLxPbmO0SM6PXtWChlWx'],
3269
+ ['994495526373444232246567036253784322009', $base62UpperLower, 'MlmlXpBMo0sm6pxTwcHLwX'],
3270
+
3271
+ ['8149613250471589625', $base64, '74PFXAZBFRv'],
3272
+ ['454064679874654562007441356949657', $base64, '1PZ6Xm9ayTgCZU5xGYP'],
3273
+ ['45422310646719874654562007441356949657', $base64, 'YB0JHWGUe4+J+zbWTxGYP'],
3274
+ ['1121921454223110646719874654562007441356949657', $base64, 'oJmRKAU1GNNBHSz/S2Q0TxGYP'],
3275
+ ['10121192145422311064671918746545620075441356949657', $base64, '1kpPyynJk/pgMxgIopD9BB+eAaYP'],
3276
+
3277
+ ['91906824217328753670', $base72, 'OdYuzDmu@os'],
3278
+ ['535903357336880946855837144765', $base72, '11;QwdMB!D)84;w@,'],
3279
+ ['3628645428648421468982810963905568210330', $base72, '3g_D_hpFwvT+jM2UiUF$eQ'],
3280
+ ['67461606287909524242401421486420908853942741199316', $base72, 'YdSH9KcqwE)dahLuF(uO,s2Y8Di'],
3281
+ ['673058295257771060991298040835276179059500055157907555831688', $base72, '2Y9hTIpkORoK;$uQNC!8u$1~9RBE1QRVG'],
3282
+
3283
+ ['79248970614563033069', $base85, '42dhgJI>!D{'],
3284
+ ['70259972284912331680149126100', $base85, '!vcNSNE+R.X.t$k'],
3285
+ ['1345211446421580809283013645361855592276', $base85, '3E0H]t@k=%[$4EHpk/WV6'],
3286
+ ['92817563463558871408829910215554937029176299613741', $base85, 'R%GwIo]>peBh?fLxaPWsYp%I16'],
3287
+ ['105332456216236666737534759570691835270616864952881377663761', $base85, 'd!qFsWcY1Q6IuAU{50jN6?nK=lFms11'],
3288
+
3289
+ ['82164606170768213165', $base95, '1ZY-^xBX,-A'],
3290
+ ['524820792661006993039498194693', $base95, '1Cwv({YtIbrPpE]r'],
3291
+ ['2500692630577003661291596854860146627030', $base95, '(Pszub<V3^Y]cs\YnU}o'],
3292
+ ['76088698829341245347114640636745832062447993955533', $base95, '2;t?i8zv}hWZ> )loCj(d7*yO3'],
3293
+ ['949872477171550708823123033931693463913459064733934993892215', $base95, '4ed~yPcS~L3d)w}!A!%R5_4Dx9u;B?0'],
3294
+ ];
3295
+ }
3296
+
3297
+ /**
3298
+ * @dataProvider providerArbitraryBaseWithInvalidAlphabet
3299
+ */
3300
+ public function testFromArbitraryBaseWithInvalidAlphabet(string $alphabet) : void
3301
+ {
3302
+ $this->expectException(\InvalidArgumentException::class);
3303
+ $this->expectExceptionMessage('The alphabet must contain at least 2 chars.');
3304
+
3305
+ BigInteger::fromArbitraryBase('0', $alphabet);
3306
+ }
3307
+
3308
+ /**
3309
+ * @dataProvider providerFromArbitraryBaseWithInvalidNumber
3310
+ */
3311
+ public function testFromArbitraryBaseWithInvalidNumber(string $number, string $alphabet, string $expectedMessage) : void
3312
+ {
3313
+ $this->expectException(NumberFormatException::class);
3314
+ $this->expectExceptionMessage($expectedMessage);
3315
+
3316
+ BigInteger::fromArbitraryBase($number, $alphabet);
3317
+ }
3318
+
3319
+ public function providerFromArbitraryBaseWithInvalidNumber() : array
3320
+ {
3321
+ return [
3322
+ ['', '01', 'The number cannot be empty.'],
3323
+ ['X', '01', 'Char "X" is not a valid character in the given alphabet.'],
3324
+ ['1', 'XY', 'Char "1" is not a valid character in the given alphabet.'],
3325
+ [' ', 'XY', 'Char " " is not a valid character in the given alphabet.'],
3326
+
3327
+ ["\x00", '01', 'Char 00 is not a valid character in the given alphabet.'],
3328
+ ["\x1F", '01', 'Char 1F is not a valid character in the given alphabet.'],
3329
+ ["\x7F", '01', 'Char 7F is not a valid character in the given alphabet.'],
3330
+ ["\x80", '01', 'Char 80 is not a valid character in the given alphabet.'],
3331
+ ["\xFF", '01', 'Char FF is not a valid character in the given alphabet.'],
3332
+ ];
3333
+ }
3334
+
3335
+ /**
3336
+ * @dataProvider providerArbitraryBaseWithInvalidAlphabet
3337
+ */
3338
+ public function testToArbitraryBaseWithInvalidAlphabet(string $alphabet) : void
3339
+ {
3340
+ $number = BigInteger::of(123);
3341
+
3342
+ $this->expectException(\InvalidArgumentException::class);
3343
+ $this->expectExceptionMessage('The alphabet must contain at least 2 chars.');
3344
+
3345
+ $number->toArbitraryBase($alphabet);
3346
+ }
3347
+
3348
+ public function providerArbitraryBaseWithInvalidAlphabet() : array
3349
+ {
3350
+ return [
3351
+ [''],
3352
+ ['0']
3353
+ ];
3354
+ }
3355
+
3356
+ public function testToArbitraryBaseOnNegativeNumber() : void
3357
+ {
3358
+ $number = BigInteger::of(-123);
3359
+
3360
+ $this->expectException(NegativeNumberException::class);
3361
+ $this->expectExceptionMessage('toArbitraryBase() does not support negative numbers.');
3362
+
3363
+ $number->toArbitraryBase('01');
3364
+ }
3365
+
3366
+ /**
3367
+ * @dataProvider providerFromBytes
3368
+ */
3369
+ public function testFromBytes(string $byteStringHex, bool $signed, string $expectedNumber) : void
3370
+ {
3371
+ $number = BigInteger::fromBytes(hex2bin($byteStringHex), $signed);
3372
+ self::assertSame($expectedNumber, (string) $number);
3373
+ }
3374
+
3375
+ public function providerFromBytes() : Generator
3376
+ {
3377
+ foreach ($this->providerToBytes() as [$expectedNumber, $signed, $byteStringHex]) {
3378
+ yield [$byteStringHex, $signed, $expectedNumber];
3379
+
3380
+ // test with extra leading bits: these should return the same number
3381
+ $prefix = ($expectedNumber[0] === '-') ? 'FF' : '00';
3382
+ yield [$prefix . $byteStringHex, $signed, $expectedNumber];
3383
+ }
3384
+ }
3385
+
3386
+ public function testFromBytesWithEmptyString() : void
3387
+ {
3388
+ $this->expectException(NumberFormatException::class);
3389
+ BigInteger::fromBytes('');
3390
+ }
3391
+
3392
+ /**
3393
+ * @dataProvider providerToBytes
3394
+ */
3395
+ public function testToBytes(string $number, bool $signed, string $expectedByteStringHex) : void
3396
+ {
3397
+ $byteString = BigInteger::of($number)->toBytes($signed);
3398
+ self::assertSame($expectedByteStringHex, strtoupper(bin2hex($byteString)));
3399
+ }
3400
+
3401
+ public function providerToBytes() : array
3402
+ {
3403
+ return [
3404
+ ['-549755813889', true, 'FF7FFFFFFFFF'],
3405
+ ['-549755813888', true, '8000000000'],
3406
+ ['-549755813887', true, '8000000001'],
3407
+ ['-4294967297', true, 'FEFFFFFFFF'],
3408
+ ['-4294967296', true, 'FF00000000'],
3409
+ ['-4294967295', true, 'FF00000001'],
3410
+ ['-4294836226', true, 'FF0001FFFE'],
3411
+ ['-4294836225', true, 'FF0001FFFF'],
3412
+ ['-4294836224', true, 'FF00020000'],
3413
+ ['-4294836223', true, 'FF00020001'],
3414
+ ['-2147483650', true, 'FF7FFFFFFE'],
3415
+ ['-2147483649', true, 'FF7FFFFFFF'],
3416
+ ['-2147483648', true, '80000000'],
3417
+ ['-16777217', true, 'FEFFFFFF'],
3418
+ ['-16777216', true, 'FF000000'],
3419
+ ['-16777215', true, 'FF000001'],
3420
+ ['-16777214', true, 'FF000002'],
3421
+ ['-16776961', true, 'FF0000FF'],
3422
+ ['-16776960', true, 'FF000100'],
3423
+ ['-16776959', true, 'FF000101'],
3424
+ ['-131073', true, 'FDFFFF'],
3425
+ ['-131072', true, 'FE0000'],
3426
+ ['-131071', true, 'FE0001'],
3427
+ ['-65537', true, 'FEFFFF'],
3428
+ ['-65536', true, 'FF0000'],
3429
+ ['-65535', true, 'FF0001'],
3430
+ ['-32769', true, 'FF7FFF'],
3431
+ ['-32768', true, '8000'],
3432
+ ['-32767', true, '8001'],
3433
+ ['-256', true, 'FF00'],
3434
+ ['-255', true, 'FF01'],
3435
+ ['-129', true, 'FF7F'],
3436
+ ['-128', true, '80'],
3437
+ ['-2', true, 'FE'],
3438
+ ['-1', true, 'FF'],
3439
+ ['0', false, '00'],
3440
+ ['0', true, '00'],
3441
+ ['1', false, '01'],
3442
+ ['1', true, '01'],
3443
+ ['127', false, '7F'],
3444
+ ['127', true, '7F'],
3445
+ ['128', false, '80'],
3446
+ ['128', true, '0080'],
3447
+ ['255', false, 'FF'],
3448
+ ['255', true, '00FF'],
3449
+ ['32767', false, '7FFF'],
3450
+ ['32767', true, '7FFF'],
3451
+ ['32768', false, '8000'],
3452
+ ['32768', true, '008000'],
3453
+ ['65535', true, '00FFFF'],
3454
+ ['65535', false, 'FFFF'],
3455
+ ['8388607', false, '7FFFFF'],
3456
+ ['8388607', true, '7FFFFF'],
3457
+ ['16777215', false, 'FFFFFF'],
3458
+ ['16777215', true, '00FFFFFF'],
3459
+
3460
+ ['-783409810830859048059', true, 'D588013FBB7EADEB85'],
3461
+ ['3938956672038786165637', false, 'D588013FBB7EADEB85'],
3462
+ ['3938956672038786165637', true, '00D588013FBB7EADEB85'],
3463
+
3464
+ ['-91749892389539817298343095779467869273987239847934', true, 'C138E088BEDB9E9052680AA1AD2E30628126C8D802'],
3465
+ ['91749892389539817298343095779467869273987239847934', false, '3EC71F774124616FAD97F55E52D1CF9D7ED93727FE'],
3466
+ ['91749892389539817298343095779467869273987239847934', true, '3EC71F774124616FAD97F55E52D1CF9D7ED93727FE'],
3467
+
3468
+ ['-172394526767171329761800221395900583757931491153922', true, '8A0AFA0F6D456BD1E23C617F037FBD9D7ED93727FE'],
3469
+ ['-201749892389539817298343095779467869273987239847934', true, 'FF75F505F092BA942E1DC39E80FC8042628126C8D802'],
3470
+ ['201749892389539817298343095779467869273987239847934', false, '8A0AFA0F6D456BD1E23C617F037FBD9D7ED93727FE'],
3471
+ ['201749892389539817298343095779467869273987239847934', true, '008A0AFA0F6D456BD1E23C617F037FBD9D7ED93727FE'],
3472
+
3473
+ ['-1098858588416703775195092613', true, 'FC730BA48F28911AA6FEA97B'],
3474
+ ['-47083115471922296524820850', true, 'D90DC332265BB003412E8E'],
3475
+ ['-943932252431784472316642258806', true, 'F415FD8A8DB757E5DEE38D108A'],
3476
+ ['-341852484393431150693130917974925642410', true, 'FEFED19B3B597B4992D424EE7BD763F556'],
3477
+ ['-283182252236038840253195025971128832705', true, 'FF2AF51502896F66B16A61FA4BEC0FED3F'],
3478
+ ['-81924191665932376117353149384682167256990062702727', true, 'C7F1F831608910CA847BBA5B9DF78D73739BB48F79'],
3479
+ ['-2895870591297216468400157702565925141502115543810', true, 'FE04C0ABEE0B5802122B7FD1F45DED3CF86FFA84FE'],
3480
+ ['-3119445165109880695968047110078654901', true, 'FDA7377A9CBAD40D92C5CCE93A6F164B'],
3481
+ ['-2416303054131084339036838954993158636473528506132', true, 'FE58C13944FC5542742BC6EA5E664ADFA371C5A8EC'],
3482
+ ['-96872708052717571315623430142461871949402837084399', true, 'BDB78D88F9EF374F0B36B23A65DD2615A59BF41711'],
3483
+ ['-406488096345576796461719102940335', true, 'EBF5661F78276E1983AF850C1B51'],
3484
+ ['-1136451083331321373659312404693395966315', true, 'FCA9077B9A9F25AFE8EE567A89496BF695'],
3485
+ ['-9050047939578973554450039239', true, 'E2C1F9CE23F97DC6337CFE39'],
3486
+ ['-5020359323944618072504884280451', true, 'C0A258196411C027A1914FC37D'],
3487
+ ['-2328315909540727378430095354579827047745865', true, 'E545B1CAFB737E6A5D994EAA63580370B6B7'],
3488
+ ['-431858509646237776589820167124236054397', true, 'FEBB1B139272FB6CCCC9D2CB50DC60D083'],
3489
+ ['-708427585499922108210831863881916427823432', true, 'F7DE1E51F72FEE6C276F8CCA9FBC229396B8'],
3490
+ ['-810836550712511504071418602', true, 'FD614AAE82643E8BD8199D16'],
3491
+ ['-6250094231931483341539582450667557086996', true, 'EDA1F3A2E7B5E2962FB0FB18DEF76618EC'],
3492
+ ['-793694724265757042363818257818', true, 'F5FB6F1C9F0A05158C27ACD266'],
3493
+ ['-823570289597131761777978989763', true, 'F59AE69F9536B419206BC2A33D'],
3494
+ ['-48802520147365020361534264877157131084794152', true, 'FDCFC6487CA9AF6AD8FDC3ECD07F242B9D76D8'],
3495
+ ['-29698333286094898756573847056234', true, 'FE8927827B08DDF695EE01D49096'],
3496
+ ['-9259920943214103669706837547526283204815967139517', true, 'F9AA02C8B97A22134B8BBED296110C43D555414943'],
3497
+ ['-1329712773661524524246281239430805224', true, 'FEFFE8193E33131F8545B3E0F3B24918'],
3498
+ ['-1901878901152859921638714839336301950184917', true, 'EA2AE1575DFCFCADE087008E55F43283522B'],
3499
+ ['-211851840428790382900097129102333609377496150', true, 'F6800F655A76F12A036BB19813EFB9747483AA'],
3500
+ ['-4567388417903078950492095', true, 'FC38D160B3521CD8AD2841'],
3501
+ ['-369549145795669040781019236477391675536381', true, 'FBC1FE1F6B3FA12F0C15EBB2D1D8E538CC03'],
3502
+ ['-1576138934203079166729265319520498113775', true, 'FB5E3EAED9C484CAE2D719313D1637A311'],
3503
+ ['-6479164160394946817944469', true, 'FAA3FBCE9C2BC0BBB6146B'],
3504
+ ['-4973786449177733351701364077033', true, 'C138D4473C207E31820C000E17'],
3505
+ ['-711073252382098058231709543027', true, 'F70665FDD48CBF58C89DEE558D'],
3506
+ ['-6006367085080317337477614662241', true, 'B43061986886506ED2DB7C0D9F'],
3507
+ ['-7794702879691249399247142997073094893', true, 'FA22CB7A161C24BF1AA59BEFD13F9713'],
3508
+ ['-92678975046563530462161825', true, 'B35676B20EDD0B3DB4945F'],
3509
+ ['-15677635845925377762958659902912102793958926170', true, 'FD40FD9112795C35521FE70F98D7AB063937D8A6'],
3510
+ ['-4670095405709769649548288171872688313', true, 'FC7C9284F8F7E995E1AA712740D6E747'],
3511
+ ['-174516040067109253897831812572', true, 'FDCC1BB70F489CA9DAD93C7224'],
3512
+ ['-78545859497424473138903230802367665200', true, 'C4E89E22CED860B9E55E8CEE89272BD0'],
3513
+ ['-13497065900825560235714337812912830643153659021435', true, 'F6C3D2A20A423123AD1E0EFD8BDF5BB3A8AA4B3785'],
3514
+ ['-5596555173616744352812136520441802', true, 'FEEC118AEF4D06D0F643CD39A0A036'],
3515
+ ['-99255515845082927316486933856906', true, 'FB1B38219A9F958666994AC9BD76'],
3516
+ ['-214375103475158898441935629946159638332', true, 'FF5EB8DB5D0D435EDD4E7636018B6BD8C4'],
3517
+ ['-1317075184740725940950186258631', true, 'EF604CF120DE2E2811BD2D0F39'],
3518
+ ['-806295473821796646961606303367289386895057', true, 'F6BE82B44B55536F7AD05829B2D0E446F92F'],
3519
+ ['-891519425610904878565592597054470339680', true, 'FD614B9AAE3F585049CBBB14E0D0E643A0'],
3520
+ ['-348541235698230937744111503200245977926', true, 'FEF9C96654CDCC22ECB72A1199D5C4ECBA'],
3521
+ ['-92998623857448524743006503658281', true, 'FB6A313D59DB9A33234E975A9CD7'],
3522
+ ['-136107716767751306827369763', true, '8F6A11E3B0E7D7502672DD'],
3523
+ ['-26859090460874041069092334', true, 'E9C85DC9DF834329D8C212'],
3524
+ ['-141333871744599151791049755944272203632', true, '95AC161FF4636C67912F85933AD4F090'],
3525
+ ['-46954121389748005216797591', true, 'D92913FAA69544689EBC69'],
3526
+ ['-596904336055990562119362462070166572406242', true, 'F925DB1686886353785D68E8CA74225D6A1E'],
3527
+ ['-1344405286102205040892162', true, 'FEE34FA4B63686D9E0E6FE'],
3528
+ ['-35964005242894495033684813312891910672337147', true, 'FE6327499A42D08BAC1085C45A9407C6343705'],
3529
+ ['-601198613094225698564174314', true, 'FE0EB33DE1204120F92A8E16'],
3530
+ ['-7610885901830744730460664472229465802332051013', true, 'FEAAB7508B4AF39EBD10BB35DEE829EAA085E9BB'],
3531
+ ['-1306992083698354560765415156364', true, 'EF80E17CD3A4F68C57C19B9574'],
3532
+ ['-5928426295029435752295941280931458449876298746999', true, 'FBF1902BB8510536016F32111424AB0A6CD3383389'],
3533
+ ['-9896625370984316971469780243746442575622', true, 'E2EA9B48F364ADED599F896DE43FFE00FA'],
3534
+ ['-3443717087795173563395198312020096617495', true, 'F5E13C36CCBFD3BF48E8688F60D14773E9'],
3535
+ ['-2245494922030817093415463801401387705038026', true, 'E6391560F819594E246C4D49BD740B1A0B36'],
3536
+ ['-69920118812045303946652729', true, 'C629D6C3A1172598A453C7'],
3537
+ ['-4649308422069845482348722740', true, 'F0FA2EA5696E1650D31845CC'],
3538
+ ['-5944629567503254036792469', true, 'FB152CFC442118BA8E3B6B'],
3539
+ ['-127287547939906994889167955101580269246', true, 'A03D4F5B5716DB273873287F6293E942'],
3540
+ ['-248002284366499376793080698841650655398888883699', true, 'D48F316557240A553B65D99CA1F51451CE45BA0D'],
3541
+ ['-23473333872646511990633448370574', true, 'FED7B9914EFDF4213635B8A38E72'],
3542
+ ['-90081289425957678036534683340022400330665092189', true, 'F0389D82E9997BB33DA87E67B4EB1A6B5C2B1BA3'],
3543
+ ['-6131774766767685247732809530507373880274956199801', true, 'FBCDF1B5BEDFF595F230E7B317BE86109C9B69D887'],
3544
+ ['-61408144425269671111963032819693687372', true, 'D1CD38B99CA0A4509A2EDFE54C616DB4'],
3545
+ ['-941883884450958161905398530967842844601553049', true, 'D5C3B40968036422C7EEF2E68DF7334E56EF67'],
3546
+ ['-51724104392679606989886993', true, 'D536FEAEB06C0DAAB3E9EF'],
3547
+ ['-7845325374205082456600697444541989', true, 'FE7D3212874987D41E2B1FD67759DB'],
3548
+ ['-79955574961153464592840377369552710119732773113197', true, 'C94ACC04DB0A580C682581F29DE7F917975ED03293'],
3549
+ ['-532195364082905073623316433892356', true, 'E5C2C008BD72041F6A6D25018BFC'],
3550
+ ['-8005009342287066447355401475', true, 'E6226956042AF014723AAAFD'],
3551
+ ['-337940679109885279728604443841584448', true, 'BEEA3CF59F4C86BED2CC426CF122C0'],
3552
+ ['-4605847097510366708547861415', true, 'F11E21F0898355E7A28DC459'],
3553
+ ['-3670015713617629611716762176813', true, 'D1AD8A2767FDC96D50E15372D3'],
3554
+ ['-649830629891966673736057405236704', true, 'DFF5FBFD829F4C38BED79AC51A20'],
3555
+ ['-3709825918305227929540638847125221526396079333457', true, 'FD762DA7043EC89E94DADCB451C4A0ECD5701D9FAF'],
3556
+ ['-43178624890438204804613583850151437', true, 'F7AF212255EE0F1FBFCA5B5DB861F3'],
3557
+ ['-7905675446580131577998272825821630231042938673', true, 'FE9D7F4BEECA706A5190AACF62EC09E62CB2A8CF'],
3558
+ ['-61457863674470726296386500810', true, 'FF396B3F26641B6F2D89CA8736'],
3559
+ ['-49308204466516796640462839998', true, 'FF60AD358FCD59D1EF5890DF42'],
3560
+ ['-4979647065425719032196358813843940678', true, 'FC40F471BB8B445D875ACB04DB709ABA'],
3561
+ ['-72543680230619431272714746061676621865910', true, 'FF2AD03365935BE6E56CABBFE041B283DC4A'],
3562
+ ['-233612491615341559436220748', true, 'FF3EC2A1741B823AD9F8E6B4'],
3563
+ ['-410572465760268592909453253610755651060159', true, 'FB496F9B6298819BED5A2C9CE83EA41F3E41'],
3564
+ ['-4440664570334327036040778362262541337800286366939', true, 'FCF629B6BD303417FDD8BEE8BA60DC0032DDD89325'],
3565
+ ['-441843788011967692225334039493087710', true, 'AAE76B59CB82AD64D35F8B5885EE22'],
3566
+ ['-8368143068213706891940405000138132955224063160906', true, 'FA46377CAD1AF23A85E9E3A934EDB4475109C6CDB6'],
3567
+ ['-829172234357769818909006249228426999062454628039', true, 'FF6EC2A18EA2660725C6EED1C62F883976C6479139'],
3568
+ ['-5906586101908186721958760602074196491', true, 'FB8E6ED2410E62DB7516A0C8A3D655F5'],
3569
+ ['-108107432789789110223831515005384896', true, 'EB2DE45D03682F7719DE19C5790740'],
3570
+ ['-5689187603712743059853316', true, 'FB4B4485A30709DBDE6FFC'],
3571
+ ['-2099146868847492866997101785005721844566', true, 'F9D4C704CD95F8CDB3722115B394C904AA'],
3572
+ ['-79222222171395055207251479752239744334172', true, 'FF172FD301840D0C03A91C2B8A30C86B46A4'],
3573
+
3574
+ ['-5522712836598149970513187952362000928321873336', true, 'FF085A5DA5FE6298EE2CC3271314D088CF435A48'],
3575
+ ['-5626380784733548014139646923816473885490489486', true, 'FF03B450EE0FABA8DF623760716CA5D94EA8D772'],
3576
+ ['-83014840727912357366146247329067270452639', true, 'FF0C0A933DC99D7267680165F0648DEF4A61'],
3577
+ ['-84461440308411103403421598199499894063437', true, 'FF07CA464BE094F0CA033746E2906BAB7EB3'],
3578
+ ['-19888885585920803236496419582873', true, 'FF04F78B70237396B8B928480C67'],
3579
+ ['-19350969325241189350680714728748', true, 'FF0BC1A5570DA847041C92C12AD4'],
3580
+ ['-75629136915615836759583377746', true, 'FF0BA10B50A4EFB0C8C4FBB6AE'],
3581
+ ['-5635103981671263600594400878193141287978133527', true, 'FF03502DC2145B71430CB94A065996E495A217E9'],
3582
+ ['-5376200015943869384474757131064327029707233723', true, 'FF0EEC402183DB518AC909E67E9F7794F38C2645'],
3583
+ ['-1322065057338692577952426752557825090', true, 'FF016128FE63A069FF7B1DB3A05243BE'],
3584
+ ['-83288572456745425681424028120956120704954', true, 'FF0B3CA46D934BA9B001BA99A25FC96E5846'],
3585
+ ['-304214315569945292283687790', true, 'FF045C1CE86BB9207E3A4C92'],
3586
+ ];
3587
+ }
3588
+
3589
+ public function testToBytesNotSignedWithNegativeNumber() : void
3590
+ {
3591
+ $number = BigInteger::of(-1);
3592
+ $this->expectException(NegativeNumberException::class);
3593
+ $number->toBytes(false);
3594
+ }
3595
+
3596
+ /**
3597
+ * @dataProvider providerRandomBits
3598
+ */
3599
+ public function testRandomBits(int $numBits, string $randomBytesHex, string $expectedNumber) : void
3600
+ {
3601
+ $randomBytesGenerator = function(int $numBytes) use ($randomBytesHex) : string {
3602
+ $randomBytes = hex2bin($randomBytesHex);
3603
+ $randomBytesLength = strlen($randomBytes);
3604
+
3605
+ if ($randomBytesLength !== $numBytes) {
3606
+ self::fail(
3607
+ "randomBits() was expected to request $randomBytesLength bytes, " .
3608
+ "but requested $numBytes bytes instead."
3609
+ );
3610
+ }
3611
+
3612
+ return $randomBytes;
3613
+ };
3614
+
3615
+ $actualNumber = BigInteger::randomBits($numBits, $randomBytesGenerator);
3616
+
3617
+ self::assertBigIntegerEquals($expectedNumber, $actualNumber);
3618
+ }
3619
+
3620
+ public function providerRandomBits() : array
3621
+ {
3622
+ return [
3623
+ [1, '00', '0'],
3624
+ [1, '01', '1'],
3625
+ [1, '02', '0'],
3626
+ [1, '03', '1'],
3627
+ [2, '00', '0'],
3628
+ [2, '01', '1'],
3629
+ [2, '02', '2'],
3630
+ [2, '03', '3'],
3631
+ [2, '04', '0'],
3632
+ [2, '05', '1'],
3633
+ [2, '06', '2'],
3634
+ [2, '07', '3'],
3635
+ [200, '23FA2323B9820B983E098309280D98ACF34793874972398329', '225831908602167927061252758557915341525679553904533200012073'],
3636
+ [199, '23FA2323B9820B983E098309280D98ACF34793874972398329', '225831908602167927061252758557915341525679553904533200012073'],
3637
+ [199, 'A3FA2323B9820B983E098309280D98ACF34793874972398329', '225831908602167927061252758557915341525679553904533200012073'],
3638
+ [198, '23FA2323B9820B983E098309280D98ACF34793874972398329', '225831908602167927061252758557915341525679553904533200012073'],
3639
+ [198, 'E3FA2323B9820B983E098309280D98ACF34793874972398329', '225831908602167927061252758557915341525679553904533200012073'],
3640
+ [197, '23FA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3641
+ [197, 'C3FA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3642
+ [196, '23FA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3643
+ [196, 'D3FA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3644
+ [195, '23FA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3645
+ [195, 'DBFA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3646
+ [194, '23FA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3647
+ [194, 'DFFA2323B9820B983E098309280D98ACF34793874972398329', '24964653069794142618507497015270016210404179681684095599401'],
3648
+ [193, '23FA2323B9820B983E098309280D98ACF34793874972398329', '12410449599020781090835918168854683378199468792756026573609'],
3649
+ [193, 'FFFA2323B9820B983E098309280D98ACF34793874972398329', '12410449599020781090835918168854683378199468792756026573609'],
3650
+ ];
3651
+ }
3652
+
3653
+ public function testRandomBitsWithNegativeBits() : void
3654
+ {
3655
+ $this->expectException(\InvalidArgumentException::class);
3656
+ BigInteger::randomBits(-1);
3657
+ }
3658
+
3659
+ public function testRandomBitsWithZeroBits() : void
3660
+ {
3661
+ $random = BigInteger::randomBits(0);
3662
+ self::assertBigIntegerEquals('0', $random);
3663
+ }
3664
+
3665
+ /**
3666
+ * @dataProvider providerRandomRange
3667
+ */
3668
+ public function testRandomRange(string $min, string $max, array $randomBytesHex, string $expectedNumber) : void
3669
+ {
3670
+ $randomBytesCounter = 0;
3671
+
3672
+ $failCounter = function() use ($randomBytesHex, & $randomBytesCounter) {
3673
+ self::fail(sprintf(
3674
+ 'randomRange() was expected to request random bytes %d time(s), but requested %d time(s) instead.',
3675
+ count($randomBytesHex),
3676
+ $randomBytesCounter
3677
+ ));
3678
+ };
3679
+
3680
+ $randomBytesGenerator = function(int $numBytes) use ($randomBytesHex, $failCounter, & $randomBytesCounter) {
3681
+ if (! isset($randomBytesHex[$randomBytesCounter])) {
3682
+ $randomBytesCounter++;
3683
+ $failCounter();
3684
+ }
3685
+
3686
+ $randomBytes = hex2bin($randomBytesHex[$randomBytesCounter]);
3687
+ $randomBytesLength = strlen($randomBytes);
3688
+
3689
+ if ($randomBytesLength !== $numBytes) {
3690
+ self::fail(
3691
+ "randomRange() was expected to request $randomBytesLength bytes, " .
3692
+ "but requested $numBytes bytes instead."
3693
+ );
3694
+ }
3695
+
3696
+ $randomBytesCounter++;
3697
+
3698
+ return $randomBytes;
3699
+ };
3700
+
3701
+ $actualNumber = BigInteger::randomRange($min, $max, $randomBytesGenerator);
3702
+
3703
+ if ($randomBytesCounter !== count($randomBytesHex)) {
3704
+ $failCounter();
3705
+ }
3706
+
3707
+ self::assertBigIntegerEquals($expectedNumber, $actualNumber);
3708
+ }
3709
+
3710
+ public function providerRandomRange() : array
3711
+ {
3712
+ return [
3713
+ ['0', '1', ['00'], '0'],
3714
+ ['0', '1', ['01'], '1'],
3715
+ ['0', '1', ['02'], '0'],
3716
+ ['0', '1', ['03'], '1'],
3717
+
3718
+ ['-2', '-1', ['00'], '-2'],
3719
+ ['-2', '-1', ['01'], '-1'],
3720
+ ['-2', '-1', ['02'], '-2'],
3721
+ ['-2', '-1', ['03'], '-1'],
3722
+
3723
+ ['-1', '1', ['00'], '-1'],
3724
+ ['-1', '1', ['01'], '0'],
3725
+ ['-1', '1', ['02'], '1'],
3726
+ ['-1', '1', ['03', '02'], '1'],
3727
+ ['-1', '1', ['FF', '03', '00'], '-1'],
3728
+ ['-1', '1', ['FF', '03', '01'], '0'],
3729
+ ['-1', '1', ['FF', '03', '02'], '1'],
3730
+
3731
+ ['1', '255', ['00'], '1'],
3732
+ ['1', '255', ['01'], '2'],
3733
+ ['1', '255', ['FD'], '254'],
3734
+ ['1', '255', ['FE'], '255'],
3735
+ ['1', '255', ['FF', '0A'], '11'],
3736
+
3737
+ ['-1', '255', ['0000'], '-1'],
3738
+ ['-1', '255', ['0001'], '0'],
3739
+ ['-1', '255', ['0100'], '255'],
3740
+ ['-1', '255', ['0300'], '255'],
3741
+ ['-1', '255', ['0301', 'F0FF'], '254'],
3742
+ ['-1', '255', ['FFFF', 'FBFF', 'FAFF'], '254'],
3743
+ ];
3744
+ }
3745
+
3746
+ public function testRandomRangeWithMinGreaterThanMax() : void
3747
+ {
3748
+ $this->expectException(MathException::class);
3749
+ BigInteger::randomRange(3, 2);
3750
+ }
3751
+
3752
+ public function testRandomRangeWithSingleValue() : void
3753
+ {
3754
+ $value = '123456789123456789123456789123456789';
3755
+ $random = BigInteger::randomRange($value, $value);
3756
+ self::assertBigIntegerEquals($value, $random);
3757
+ }
3758
+
3759
+ public function testSerialize() : void
3760
+ {
3761
+ $value = '-1234567890987654321012345678909876543210123456789';
3762
+
3763
+ $number = BigInteger::of($value);
3764
+
3765
+ self::assertBigIntegerEquals($value, \unserialize(\serialize($number)));
3766
+ }
3767
+
3768
+ public function testDirectCallToUnserialize() : void
3769
+ {
3770
+ $this->expectException(\LogicException::class);
3771
+ BigInteger::zero()->unserialize('123');
3772
+ }
3773
+
3774
+ public function testJsonSerialize() : void
3775
+ {
3776
+ $value = '-1234567890987654321012345678909876543210123456789';
3777
+
3778
+ $number = BigInteger::of($value);
3779
+
3780
+ self::assertSame($value, $number->jsonSerialize());
3781
+ }
3782
+ }