2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:35:26 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.bcpowmod" xmlns="http://docbook.org/ns/docbook">
|
2007-01-27 00:21:08 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>bcpowmod</refname>
|
|
|
|
<refpurpose>Raise an arbitrary precision number to another, reduced by a specified modulus</refpurpose>
|
|
|
|
</refnamediv>
|
2007-01-27 16:51:44 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-01-27 00:21:08 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>bcpowmod</methodname>
|
2017-09-09 12:29:42 +00:00
|
|
|
<methodparam><type>string</type><parameter>base</parameter></methodparam>
|
|
|
|
<methodparam><type>string</type><parameter>exponent</parameter></methodparam>
|
2015-04-01 19:37:26 +00:00
|
|
|
<methodparam><type>string</type><parameter>modulus</parameter></methodparam>
|
2015-12-20 00:00:25 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>scale</parameter><initializer>0</initializer></methodparam>
|
2007-01-27 00:21:08 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2007-01-27 16:51:44 +00:00
|
|
|
Use the fast-exponentiation method to raise
|
2017-09-09 12:29:42 +00:00
|
|
|
<parameter>base</parameter> to the power
|
|
|
|
<parameter>exponent</parameter> with respect to the modulus
|
2007-01-27 16:51:44 +00:00
|
|
|
<parameter>modulus</parameter>.
|
2007-01-27 00:21:08 +00:00
|
|
|
</para>
|
2007-01-27 16:51:44 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2017-09-09 12:29:42 +00:00
|
|
|
<term><parameter>base</parameter></term>
|
2007-01-27 16:51:44 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-09-09 12:29:42 +00:00
|
|
|
The base, as an integral string (i.e. the scale has to be zero).
|
2007-01-27 16:51:44 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2017-09-09 12:29:42 +00:00
|
|
|
<term><parameter>exponent</parameter></term>
|
2007-01-27 16:51:44 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-09-09 12:29:42 +00:00
|
|
|
The exponent, as an non-negative, integral string (i.e. the scale has to be zero).
|
2007-01-27 16:51:44 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>modulus</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-09-09 12:29:42 +00:00
|
|
|
The modulus, as an integral string (i.e. the scale has to be zero).
|
2007-01-27 16:51:44 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
&bc.scale.description;
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2007-01-27 16:58:59 +00:00
|
|
|
Returns the result as a string, or &null; if <parameter>modulus</parameter>
|
2017-09-09 12:29:42 +00:00
|
|
|
is <literal>0</literal> or <parameter>exponent</parameter> is negative.
|
2007-01-27 16:51:44 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
2007-01-27 00:21:08 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
2010-08-26 15:36:56 +00:00
|
|
|
Because this method uses the modulus operation, numbers which are not
|
|
|
|
positive integers may give unexpected results.
|
2007-01-27 00:21:08 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</refsect1>
|
2007-01-27 16:51:44 +00:00
|
|
|
|
|
|
|
<refsect1 role="examples">
|
2007-01-27 00:21:08 +00:00
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
The following two statements are functionally identical. The
|
|
|
|
<function>bcpowmod</function> version however, executes in
|
|
|
|
less time and can accept larger parameters.
|
|
|
|
<informalexample>
|
|
|
|
<programlisting role="php">
|
2002-12-10 20:33:41 +00:00
|
|
|
<![CDATA[
|
2002-12-11 16:34:54 +00:00
|
|
|
<?php
|
2003-12-15 16:55:22 +00:00
|
|
|
$a = bcpowmod($x, $y, $mod);
|
2002-12-10 20:33:41 +00:00
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
$b = bcmod(bcpow($x, $y), $mod);
|
|
|
|
|
2007-01-27 00:21:08 +00:00
|
|
|
// $a and $b are equal to each other.
|
2002-12-11 16:34:54 +00:00
|
|
|
|
|
|
|
?>
|
2002-12-10 20:33:41 +00:00
|
|
|
]]>
|
2007-01-27 00:21:08 +00:00
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-01-27 16:51:44 +00:00
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
2007-01-27 00:21:08 +00:00
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
2007-01-27 16:51:44 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>bcpow</function></member>
|
|
|
|
<member><function>bcmod</function></member>
|
|
|
|
</simplelist>
|
2007-01-27 00:21:08 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-12-10 20:33:41 +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-12-10 20:33:41 +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
|
|
|
|
-->
|