|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-06-26 06:31 UTC] kalle@php.net
[2020-02-07 06:10 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 08:00:02 2025 UTC |
Description: ------------ If you pass a GMP resource as parameter to gmp_fact(), it calculates and returns the factorial of the internal resource number, not of the GMP value in the resource. In the PHP manual the function prototype is given as: "resource gmp_fact ( int $a )" However, in the parameter description it says: "It can be either a GMP number resource, or a numeric string given that it is possible to convert the latter to a number." This is misleading. Furthermore gmp_fact should check the parameter type and either accept GMP resources or throw a warning. Reproduce code: --------------- <?php for ($i = 0; $i < 3; $i++) { $nine = gmp_init('9'); var_dump($nine); echo '9! = ', gmp_strval(gmp_fact($nine)), "\n"; } Expected result: ---------------- resource(4) of type (GMP integer) 9! = 362880 resource(6) of type (GMP integer) 9! = 362880 resource(8) of type (GMP integer) 9! = 362880 *** or *** resource(4) of type (GMP integer) 9! = Warning: gmp_fact(): parameter must be int resource(6) of type (GMP integer) 9! = Warning: gmp_fact(): parameter must be int resource(8) of type (GMP integer) 9! = Warning: gmp_fact(): parameter must be int Actual result: -------------- resource(4) of type (GMP integer) 9! = 24 resource(6) of type (GMP integer) 9! = 720 resource(8) of type (GMP integer) 9! = 40320