<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.bc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.bcpow.php',
    1 => 'bcpow',
    2 => '任意精度数字的乘方',
  ),
  'up' => 
  array (
    0 => 'ref.bc.php',
    1 => 'BC 数学 函数',
  ),
  'prev' => 
  array (
    0 => 'function.bcmul.php',
    1 => 'bcmul',
  ),
  'next' => 
  array (
    0 => 'function.bcpowmod.php',
    1 => 'bcpowmod',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/bc/functions/bcpow.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.bcpow" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">bcpow</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">bcpow</span> &mdash; <span class="dc-title">任意精度数字的乘方</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.bcpow-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>bcpow</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$num</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$exponent</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$scale</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   <code class="parameter">num</code> 的 <code class="parameter">exponent</code> 次方运算。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.bcpow-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">num</code></dt>
     <dd>
      <p class="para">
       string 类型的底数。
      </p>
     </dd>
    
    
     <dt><code class="parameter">exponent</code></dt>
     <dd>
      <p class="para">
       string 类型的指数。必须是没有小数部分的值。指数的有效范围取决于平台，但起码支持
       <code class="literal">-2147483648</code> 到 <code class="literal">2147483647</code> 的范围。
      </p>
     </dd>
    
    
     <dt><code class="parameter">scale</code></dt>
     <dd>
      <span class="simpara">
       此参数用于设置结果小数点后的位数。
       如果为 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>，则默认为使用 <span class="function"><a href="function.bcscale.php" class="function">bcscale()</a></span> 设置的默认精度，
       或者回退到 <a href="bc.configuration.php#ini.bcmath.scale" class="link"><code class="literal">bcmath.scale</code></a> INI 指令的值。
      </span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.bcpow-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回字符串类型的结果。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.bcpow-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   函数在下列情况会抛出 <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span>：
   <ul class="simplelist">
    <li><code class="parameter">num</code> 或 <code class="parameter">exponent</code> 不是格式正确的 BCMath 数字字符串</li>
    <li><code class="parameter">exponent</code> 有小数部分</li>
    <li><code class="parameter">exponent</code> 或 <code class="parameter">scale</code> 超出有效范围</li>
   </ul>
  </p>
  <p class="simpara">
   如果 <code class="parameter">num</code> 为 <code class="literal">0</code> 且 <code class="parameter">exponent</code>
   为负值，则此函数抛出 <span class="exceptionname"><a href="class.divisionbyzeroerror.php" class="exceptionname">DivisionByZeroError</a></span> 异常。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.bcpow-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       <code class="literal">0</code> 的负幂以前返回 <code class="literal">0</code>，但现在会引发 <span class="exceptionname"><a href="class.divisionbyzeroerror.php" class="exceptionname">DivisionByZeroError</a></span> 异常。
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       当 <code class="parameter">exponent</code> 有小数部分时，现在会抛出 <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> 而不是截断。
      </td>
     </tr>

     <tr>
      <td>7.3.0</td>
      <td>
       现在 <span class="function"><strong>bcpow()</strong></span> 可以按想要的小数点位数返回数字。
       而之前，返回的数字会忽略尾随零（trailing decimal zeroes）。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.bcpow-examples">
  <h3 class="title">示例</h3>
  <div class="example" id="example-1">
   <p><strong>示例 #1 <span class="function"><strong>bcpow()</strong></span> 示例</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bcpow</span><span style="color: #007700">(</span><span style="color: #DD0000">'4.2'</span><span style="color: #007700">, </span><span style="color: #DD0000">'3'</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">); </span><span style="color: #FF8000">// 74.08<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 notes" id="refsect1-function.bcpow-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    PHP 7.3.0 之前，<span class="function"><strong>bcpow()</strong></span> 返回的结果，小数点后的小数位数可能比 <code class="parameter">scale</code>
    参数指定的少。只有当结果不需要 <code class="parameter">scale</code> 允许的所有小数位数时，才会发生这种情况。例如：
    <div class="example" id="example-2">
     <p><strong>示例 #2 <span class="function"><strong>bcpow()</strong></span> 小数位数示例</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">bcpow</span><span style="color: #007700">(</span><span style="color: #DD0000">'5'</span><span style="color: #007700">, </span><span style="color: #DD0000">'2'</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">);     </span><span style="color: #FF8000">// 打印 "25" 而不是 "25.00"<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.bcpow-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.bcpowmod.php" class="function" rel="rdfs-seeAlso">bcpowmod()</a> - Raise an arbitrary precision number to another, reduced by a specified modulus</span></li>
    <li><span class="function"><a href="function.bcsqrt.php" class="function" rel="rdfs-seeAlso">bcsqrt()</a> - 任意精度数字的二次方根</span></li>
    <li><span class="methodname"><a href="bcmath-number.pow.php" class="methodname" rel="rdfs-seeAlso">BcMath\Number::pow()</a> - Raises an arbitrary precision number</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>