php-doc-en/reference/bc/functions/bccomp.xml

106 lines
2.7 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.bccomp" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>bccomp</refname>
<refpurpose>Compare two arbitrary precision numbers</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>bccomp</methodname>
<methodparam><type>string</type><parameter>left_operand</parameter></methodparam>
<methodparam><type>string</type><parameter>right_operand</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>scale</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
Compares the <parameter>left_operand</parameter> to the
<parameter>right_operand</parameter> and returns the result as an
integer.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>left_operand</parameter></term>
<listitem>
<para>
The left operand, as a string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>right_operand</parameter></term>
<listitem>
<para>
The right operand, as a string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>scale</parameter></term>
<listitem>
<para>
The optional <parameter>scale</parameter> parameter is used to set the
number of digits after the decimal place which will be used in the
comparison.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns 0 if the two operands are equal, 1 if the
<parameter>left_operand</parameter> is larger than the
<parameter>right_operand</parameter>, -1 otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>bccomp</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
echo bccomp('1', '2') . "\n"; // -1
echo bccomp('1.00001', '1', 3); // 0
echo bccomp('1.00001', '1', 5); // 1
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<!-- 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
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
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
-->