|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-17 01:37 UTC] jack dot nerad at comcast dot net
Description: ------------ It is a sin that PHP cannot handle negative exponents. Every other respectable language that has half the vocabulary that PHP has can handle negative exponents. Heck, even the windows calculator can handle negative exponents. Please. Mature and refine the language to include this ability. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 20:00:01 2025 UTC |
### Eclipse Workspace Patch 1.0 #P PHPDoc Index: en/reference/math/functions/pow.xml =================================================================== RCS file: /repository/phpdoc/en/reference/math/functions/pow.xml,v retrieving revision 1.11 diff -u -r1.11 pow.xml --- en/reference/math/functions/pow.xml 31 Mar 2007 19:18:23 -0000 1.11 +++ en/reference/math/functions/pow.xml 18 Apr 2007 20:18:37 -0000 @@ -16,11 +16,6 @@ Returns <parameter>base</parameter> raised to the power of <parameter>exp</parameter>. </para> - <note> - <para> - PHP cannot handle negative <parameter>exp</parameter>s. - </para> - </note> <warning> <para> In PHP 4.0.6 and earlier <function>pow</function> always returnedI apologize for not taking a better look at this documentation bug. It appears that from bug#25751 was the first one to report that you cannot use negative bases in pow(). This is because it in the bug report, it would have resulted in a complex number, which PHP (at that time) did not support. I am unsure if PHP supports complex numbers at this time. In the bug report, it had shown a bogus result for the computation. In the comments for math.c, version 1.69 it said that for PHP <=4.0.6 it would return bogus results for the Windows platform. Since the bug report did not include a version number, I would assume that it was using that version. In bug#40729, it was shown that PHP can do negative bases in an example, and they assumed that it was a mistake made in the the pow() documentation, and that what they meant was that it couldn?t do negative exponents (an error in the fix for #25751). The documentation was then changed to say it cannot handle negative powers. I am not sure how you wanted the examples to be commented though, so I did what I thought was best. ### Eclipse Workspace Patch 1.0 #P PHPDoc Index: en/reference/math/functions/pow.xml =================================================================== RCS file: /repository/phpdoc/en/reference/math/functions/pow.xml,v retrieving revision 1.11 diff -u -r1.11 pow.xml --- en/reference/math/functions/pow.xml 31 Mar 2007 19:18:23 -0000 1.11 +++ en/reference/math/functions/pow.xml 19 Apr 2007 02:24:46 -0000 @@ -16,11 +16,6 @@ Returns <parameter>base</parameter> raised to the power of <parameter>exp</parameter>. </para> - <note> - <para> - PHP cannot handle negative <parameter>exp</parameter>s. - </para> - </note> <warning> <para> In PHP 4.0.6 and earlier <function>pow</function> always returned @@ -76,7 +71,8 @@ <entry>Since 4.0.6</entry> <entry> The function will now return <type>integer</type> results if possible, - before this it always returned a <type>float</type> result. + before this it always returned a <type>float</type> result. For older + versions, you may receive a bogus result for complex numbers. </entry> </row> <row> @@ -104,8 +100,8 @@ echo pow(-1, 20); // 1 echo pow(0, 0); // 1 -echo pow(-1, 5.5); // error - +echo pow(-1, 5.5); // PHP >4.0.6 NAN +echo pow(-1, 5.5); // PHP <=4.0.6 1.#IND ?> ]]> </programlisting>