2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 07:54:14 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.pow" xmlns="http://docbook.org/ns/docbook">
|
2007-03-31 10:43:52 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>pow</refname>
|
|
|
|
<refpurpose>Exponential expression</refpurpose>
|
|
|
|
</refnamediv>
|
2007-03-31 11:20:55 +00:00
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-03-31 10:43:52 +00:00
|
|
|
<methodsynopsis>
|
2020-11-02 09:17:09 +00:00
|
|
|
<type class="union"><type>int</type><type>float</type></type><methodname>pow</methodname>
|
|
|
|
<methodparam><type class="union"><type>int</type><type>float</type></type><parameter>base</parameter></methodparam>
|
|
|
|
<methodparam><type class="union"><type>int</type><type>float</type></type><parameter>exp</parameter></methodparam>
|
2007-03-31 10:43:52 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns <parameter>base</parameter> raised to the power of
|
2007-03-31 19:18:23 +00:00
|
|
|
<parameter>exp</parameter>.
|
2007-03-31 10:43:52 +00:00
|
|
|
</para>
|
2014-06-01 22:43:11 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
In PHP 5.6 onwards, you may prefer to use the
|
|
|
|
<link linkend="language.operators.arithmetic">**</link> operator.
|
|
|
|
</para>
|
|
|
|
</note>
|
2007-03-31 10:43:52 +00:00
|
|
|
</refsect1>
|
2007-03-31 11:20:55 +00:00
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2007-03-31 19:18:23 +00:00
|
|
|
<term><parameter>base</parameter></term>
|
2007-03-31 11:20:55 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-03-31 19:18:23 +00:00
|
|
|
The base to use
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>exp</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The exponent
|
2007-03-31 11:20:55 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2007-03-31 19:18:23 +00:00
|
|
|
<parameter>base</parameter> raised to the power of <parameter>exp</parameter>.
|
2012-03-04 19:08:18 +00:00
|
|
|
If both arguments are non-negative integers and the result can be represented
|
2020-11-02 15:39:04 +00:00
|
|
|
as an integer, the result will be returned with <type>int</type> type,
|
2012-03-04 19:08:18 +00:00
|
|
|
otherwise it will be returned as a <type>float</type>.
|
2007-03-31 19:18:23 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-03-31 11:20:55 +00:00
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
2007-03-31 19:18:23 +00:00
|
|
|
<example>
|
|
|
|
<title>Some examples of <function>pow</function></title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
var_dump(pow(2, 8)); // int(256)
|
|
|
|
echo pow(-1, 20); // 1
|
|
|
|
echo pow(0, 0); // 1
|
2016-08-29 12:54:01 +00:00
|
|
|
echo pow(10, -1); // 0.1
|
2007-03-31 11:20:55 +00:00
|
|
|
|
2016-08-29 12:54:01 +00:00
|
|
|
echo pow(-1, 5.5); // PHP >=5.2.2: NAN
|
|
|
|
echo pow(-1, 5.5); // PHP <5.2.2: -NAN
|
2007-03-31 19:18:23 +00:00
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
2007-03-31 11:20:55 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2011-08-17 10:50:30 +00:00
|
|
|
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
This function will convert all input to a number, even non-scalar values,
|
|
|
|
which could lead to <literal>weird</literal> results.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</refsect1>
|
|
|
|
|
2007-03-31 11:20:55 +00:00
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
2007-03-31 19:18:23 +00:00
|
|
|
<member><function>exp</function></member>
|
|
|
|
<member><function>sqrt</function></member>
|
|
|
|
<member><function>bcpow</function></member>
|
|
|
|
<member><function>gmp_pow</function></member>
|
2007-03-31 11:20:55 +00:00
|
|
|
</simplelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-03-31 10:43:52 +00:00
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|