<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.bcpowmod.php',
    1 => 'bcpowmod',
    2 => 'Raise an arbitrary precision number to another, reduced by a specified modulus',
  ),
  'up' => 
  array (
    0 => 'ref.bc.php',
    1 => 'Функції BC Math',
  ),
  'prev' => 
  array (
    0 => 'function.bcpow.php',
    1 => 'bcpow',
  ),
  'next' => 
  array (
    0 => 'function.bcround.php',
    1 => 'bcround',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/bc/functions/bcpowmod.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.bcpowmod" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">bcpowmod</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">bcpowmod</span> &mdash; <span class="dc-title">Raise an arbitrary precision number to another, reduced by a specified modulus</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.bcpowmod-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>bcpowmod</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$num</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$exponent</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$modulus</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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><br>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Use the fast-exponentiation method to raise 
   <code class="parameter">num</code> to the power
   <code class="parameter">exponent</code> with respect to the modulus
   <code class="parameter">modulus</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.bcpowmod-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">num</code></dt>
     <dd>
      <p class="para">
       The base, as an integral string (i.e. the scale has to be zero).
      </p>
     </dd>
    
    
     <dt><code class="parameter">exponent</code></dt>
     <dd>
      <p class="para">
       The exponent, as an non-negative, integral string (i.e. the scale has to be zero).
      </p>
     </dd>
    
    
     <dt><code class="parameter">modulus</code></dt>
     <dd>
      <p class="para">
       The modulus, as an integral string (i.e. the scale has to be zero).
      </p>
     </dd>
    
    
     <dt><code class="parameter">scale</code></dt>
     <dd>
      <span class="simpara">
       This parameter is used to set the number of digits after the decimal place in the result.
       If <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, it will default to the default scale set with <span class="function"><a href="function.bcscale.php" class="function">bcscale()</a></span>,
       or fallback to the value of the
       <a href="bc.configuration.php#ini.bcmath.scale" class="link"><code class="literal">bcmath.scale</code></a> INI directive.
      </span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.bcpowmod-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the result as a string.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.bcpowmod-errors">
  <h3 class="title">Помилки/виключення</h3>
  <p class="para">
   This function throws a <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> in the following cases:
   <ul class="simplelist">
    <li><code class="parameter">num</code>, <code class="parameter">exponent</code> or <code class="parameter">modulus</code> is not a well-formed BCMath numeric string</li>
    <li><code class="parameter">num</code>, <code class="parameter">exponent</code> or <code class="parameter">modulus</code> has a fractional part</li>
    <li><code class="parameter">exponent</code> is a negative value</li>
    <li><code class="parameter">scale</code> is outside the valid range</li>
   </ul>
  </p>
  <p class="simpara">
   This function throws a <span class="exceptionname"><a href="class.divisionbyzeroerror.php" class="exceptionname">DivisionByZeroError</a></span> exception if <code class="parameter">modulus</code>
   is <code class="literal">0</code>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.bcpowmod-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">scale</code> is now nullable.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       Now throws a <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> instead of returning <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if <code class="parameter">exponent</code> is a negative value.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       Dividing by <code class="literal">0</code> now throws a <span class="exceptionname"><a href="class.divisionbyzeroerror.php" class="exceptionname">DivisionByZeroError</a></span> exception instead of returning <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.bcpowmod-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   The following two statements are functionally identical.  The
   <span class="function"><strong>bcpowmod()</strong></span> version however, executes in
   less time and can accept larger parameters.
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">bcpowmod</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">, </span><span style="color: #0000BB">$y</span><span style="color: #007700">, </span><span style="color: #0000BB">$mod</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">bcmod</span><span style="color: #007700">(</span><span style="color: #0000BB">bcpow</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">, </span><span style="color: #0000BB">$y</span><span style="color: #007700">), </span><span style="color: #0000BB">$mod</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// $a and $b are equal to each other.<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.bcpowmod-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Because this method uses the modulus operation, numbers which are not
    positive integers may give unexpected results.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.bcpowmod-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.bcpow.php" class="function" rel="rdfs-seeAlso">bcpow()</a> - Raise an arbitrary precision number to another</span></li>
    <li><span class="function"><a href="function.bcmod.php" class="function" rel="rdfs-seeAlso">bcmod()</a> - Get modulus of an arbitrary precision number</span></li>
   <li><span class="methodname"><strong>BcMath\Number::powmod()</strong></span></li>
   </ul>
  </p>
 </div>

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