1999-06-06 18:51:02 +00:00
|
|
|
<reference id="ref.bc">
|
1999-06-20 03:04:56 +00:00
|
|
|
<title>Arbitrary precision mathematics functions</title>
|
1999-06-06 18:51:02 +00:00
|
|
|
<titleabbrev>BC math</titleabbrev>
|
|
|
|
|
|
|
|
<partintro>
|
|
|
|
<simpara>
|
1999-06-20 03:04:56 +00:00
|
|
|
These functions are only available if PHP was configured with
|
|
|
|
<option role="configure">--enable-bcmath</option>.
|
1999-06-06 18:51:02 +00:00
|
|
|
</partintro>
|
1999-06-20 03:04:56 +00:00
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.bcadd">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcadd</refname>
|
|
|
|
<refpurpose>Add two arbitrary precision numbers.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcadd</function></funcdef>
|
|
|
|
<paramdef>string <parameter>left operand</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>right operand</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter><optional>scale</optional></parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Adds the <parameter>left operand</parameter> to the
|
|
|
|
<parameter>right operand</parameter> and returns the
|
|
|
|
sum in a string. The optional <parameter>scale</parameter>
|
|
|
|
parameter is used to set the number of digits after the decimal
|
|
|
|
place in the result.
|
|
|
|
<para>
|
|
|
|
See also <function>bcsub</function>.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bccomp">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bccomp</refname>
|
|
|
|
<refpurpose>Compare two arbitrary precision numbers.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>int <function>bccomp</function></funcdef>
|
|
|
|
<paramdef>string <parameter>left operand</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>right operand</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter><optional>scale</optional></parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Compares the <parameter>left operand</parameter> to the
|
|
|
|
<parameter>right operand</parameter> and returns the
|
|
|
|
result as an integer. The optional <parameter>scale</parameter>
|
|
|
|
parameter is used to set the number of digits after the decimal place
|
|
|
|
which will be used in the comparion. The return value is 0 if the
|
|
|
|
two operands are equal. If the <parameter>left operand</parameter>
|
|
|
|
is larger than the <parameter>right operand</parameter> the return
|
|
|
|
value is +1 and if the <parameter>left operand</parameter> is less than
|
|
|
|
the <parameter>right operand</parameter> the return value is -1.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcdiv">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcdiv</refname>
|
|
|
|
<refpurpose>Divide two arbitrary precision numbers.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcdiv</function></funcdef>
|
|
|
|
<paramdef>string <parameter>left operand</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>right operand</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter><optional>scale</optional></parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Divides the <parameter>left operand</parameter> by the
|
|
|
|
<parameter>right operand</parameter> and returns the result. The optional
|
|
|
|
<parameter>scale</parameter> sets the number of digits after the decimal
|
|
|
|
place in the result.
|
|
|
|
|
|
|
|
<para>
|
|
|
|
See also <function>bcmul</function>.
|
|
|
|
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcmod">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcmod</refname>
|
|
|
|
<refpurpose>Get modulus of an arbitrary precision number.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcmod</function></funcdef>
|
|
|
|
<paramdef>string <parameter>left operand</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>modulus</parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Get the modulus of the <parameter>left operand</parameter> using
|
|
|
|
<parameter>modulus</parameter>.
|
|
|
|
<para>
|
|
|
|
See also <function>bcdiv</function>.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcmul">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcmul</refname>
|
|
|
|
<refpurpose>Multiply two arbitrary precision number.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcmul</function></funcdef>
|
|
|
|
<paramdef>string <parameter>left operand</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>right operand</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter><optional>scale</optional></parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Multiply the <parameter>left operand</parameter> by the
|
|
|
|
<parameter>right operand</parameter> and returns the result. The optional
|
|
|
|
<parameter>scale</parameter> sets the number of digits after the decimal
|
|
|
|
place in the result.
|
|
|
|
|
|
|
|
<para>
|
|
|
|
See also <function>bcdiv</function>.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcpow">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcpow</refname>
|
|
|
|
<refpurpose>Raise an arbitrary precision number to another.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcpow</function></funcdef>
|
|
|
|
<paramdef>string <parameter>x</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>y</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter><optional>scale</optional></parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Raise <parameter>x</parameter> to the power <parameter>y</parameter>.
|
|
|
|
The <parameter>scale</parameter> can be used to set the number of digits
|
|
|
|
after the decimal place in the result.
|
|
|
|
<para>
|
|
|
|
See also <function>bcsqrt</function>.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcscale">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcscale</refname>
|
|
|
|
<refpurpose>Set default scale parameter for all bc math functions.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcscale</function></funcdef>
|
|
|
|
<paramdef>int <parameter>scale</parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
This function sets the default scale parameter for all subsequent bc math functions
|
|
|
|
that do not explicitly specify a scale parameter.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcsqrt">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcsqrt</refname>
|
|
|
|
<refpurpose>Get the square root of an arbitray precision number.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcsqrt</function></funcdef>
|
|
|
|
<paramdef>string <parameter>operand</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>scale</parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Return the square root of the <parameter>operand</parameter>. The
|
|
|
|
optional <parameter>scale</parameter> parameter sets the number of
|
|
|
|
digits after the decimal place in the result.
|
|
|
|
<para>
|
|
|
|
See also <function>bcpow</function>.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.bcsub">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>bcsub</refname>
|
|
|
|
<refpurpose>Subtract one arbitrary precision number from another.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcdef>string <function>bcsub</function></funcdef>
|
|
|
|
<paramdef>string <parameter>left operand</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>right operand</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter><optional>scale</optional></parameter></paramdef>
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Subtracts the <parameter>right operand</parameter> from the
|
|
|
|
<parameter>left operand</parameter> and returns the
|
|
|
|
result in a string. The optional <parameter>scale</parameter>
|
|
|
|
parameter is used to set the number of digits after the decimal
|
|
|
|
place in the result.
|
|
|
|
<para>
|
|
|
|
See also <function>bcadd</function>.
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
</reference>
|
|
|
|
|
|
|
|
<!-- 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
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|