-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bcceil, bcfloor, bcround and bcdivmod
- Loading branch information
1 parent
0e09741
commit 9110b52
Showing
7 changed files
with
646 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- $Revision$ --> | ||
<refentry xml:id="function.bcceil" xmlns="http://docbook.org/ns/docbook"> | ||
<refnamediv> | ||
<refname>bcceil</refname> | ||
<refpurpose>Round arbitrary precision number fractions up</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1 role="description"> | ||
&reftitle.description; | ||
<methodsynopsis> | ||
<type>string</type><methodname>bcceil</methodname> | ||
<methodparam><type>string</type><parameter>num</parameter></methodparam> | ||
</methodsynopsis> | ||
<para> | ||
Returns the next highest integer value by rounding up | ||
<parameter>num</parameter> if necessary. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="parameters"> | ||
&reftitle.parameters; | ||
<para> | ||
<variablelist> | ||
<varlistentry> | ||
<term><parameter>num</parameter></term> | ||
<listitem> | ||
<para> | ||
The value to round. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
</variablelist> | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="returnvalues"> | ||
&reftitle.returnvalues; | ||
<para> | ||
num rounded up to the next highest number as a string. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="examples"> | ||
&reftitle.examples; | ||
<para> | ||
<example> | ||
<title><function>ceil</function> example</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
echo bcceil('4.3'); // '5' | ||
echo bcceil('9.999'); // '10' | ||
echo bcceil('-3.14'); // '-3' | ||
?> | ||
]]> | ||
</programlisting> | ||
</example> | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; | ||
<para> | ||
<simplelist> | ||
<member><function>bcfloor</function></member> | ||
<member><function>bcround</function></member> | ||
</simplelist> | ||
</para> | ||
</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 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- $Revision$ --> | ||
<refentry xml:id="function.bcdivmod" xmlns="http://docbook.org/ns/docbook"> | ||
<refnamediv> | ||
<refname>bcdivmod</refname> | ||
<refpurpose>Get the quotient and modulus of an arbitrary precision number</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1 role="description"> | ||
&reftitle.description; | ||
<methodsynopsis> | ||
<type>string</type><methodname>bcdivmod</methodname> | ||
<methodparam><type>string</type><parameter>num1</parameter></methodparam> | ||
<methodparam><type>string</type><parameter>num2</parameter></methodparam> | ||
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>scale</parameter><initializer>&null;</initializer></methodparam> | ||
</methodsynopsis> | ||
<para> | ||
Get the quotient and remainder of dividing <parameter>num1</parameter> by | ||
<parameter>num2</parameter>. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="parameters"> | ||
&reftitle.parameters; | ||
<para> | ||
<variablelist> | ||
<varlistentry> | ||
<term><parameter>num1</parameter></term> | ||
<listitem> | ||
<para> | ||
The dividend, as a string. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term><parameter>num2</parameter></term> | ||
<listitem> | ||
<para> | ||
The divisor, as a string. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
&bc.scale.description; | ||
</variablelist> | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="returnvalues"> | ||
&reftitle.returnvalues; | ||
<para> | ||
Returns an array, the first element is the quotient as a string and the second | ||
element is the remainder as a string. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="errors"> | ||
&reftitle.errors; | ||
<para> | ||
This function throws a <classname>ValueError</classname> in the following cases: | ||
<simplelist> | ||
<member><parameter>num1</parameter> or <parameter>num2</parameter> is not a well-formed BCMath numeric string</member> | ||
<member><parameter>scale</parameter> is outside the valid range</member> | ||
</simplelist> | ||
</para> | ||
<para> | ||
This function throws a <classname>DivisionByZeroError</classname> exception if <parameter>num2</parameter> | ||
is <literal>0</literal>. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="examples"> | ||
&reftitle.examples; | ||
<example> | ||
<title><function>bcdivmod</function> example</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
bcscale(0); | ||
[$quot, $rem] = bcdivmod('5', '3'); | ||
echo $quot; // 1 | ||
echo $rem; // 2 | ||
[$quot, $rem] = bcdivmod('5', '-3'); | ||
echo $quot; // -1 | ||
echo $rem; // 2 | ||
[$quot, $rem] = bcdivmod('-5', '3'); | ||
echo $quot; // -1 | ||
echo $rem; // -2 | ||
[$quot, $rem] = bcdivmod('-5', '-3'); | ||
echo $quot; // 1 | ||
echo $rem; // -2 | ||
?> | ||
]]> | ||
</programlisting> | ||
</example> | ||
<example> | ||
<title><function>bcdivmod</function> with decimals</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
[$quot, $rem] = bcdivmod('5.7', '1.3', 1); | ||
echo $quot; // 4 | ||
echo $rem; // 0.5 | ||
?> | ||
]]> | ||
</programlisting> | ||
</example> | ||
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; | ||
<para> | ||
<simplelist> | ||
<member><function>bcdiv</function></member> | ||
<member><function>bcmod</function></member> | ||
</simplelist> | ||
</para> | ||
</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 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- $Revision$ --> | ||
<refentry xml:id="function.bcfloor" xmlns="http://docbook.org/ns/docbook"> | ||
<refnamediv> | ||
<refname>bcfloor</refname> | ||
<refpurpose>Round arbitrary precision number fractions down</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1 role="description"> | ||
&reftitle.description; | ||
<methodsynopsis> | ||
<type>string</type><methodname>bcfloor</methodname> | ||
<methodparam><type>string</type><parameter>num</parameter></methodparam> | ||
</methodsynopsis> | ||
<para> | ||
Returns the next lowest integer value by rounding down | ||
<parameter>num</parameter> if necessary. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="parameters"> | ||
&reftitle.parameters; | ||
<para> | ||
<variablelist> | ||
<varlistentry> | ||
<term><parameter>num</parameter></term> | ||
<listitem> | ||
<para> | ||
The value to round. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
</variablelist> | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="returnvalues"> | ||
&reftitle.returnvalues; | ||
<para> | ||
num rounded down to the next lowest number as a string. | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="examples"> | ||
&reftitle.examples; | ||
<para> | ||
<example> | ||
<title><function>ceil</function> example</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
echo bcfloor('4.3'); // '4' | ||
echo bcfloor('9.999'); // '9' | ||
echo bcfloor('-3.14'); // '-4' | ||
?> | ||
]]> | ||
</programlisting> | ||
</example> | ||
</para> | ||
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; | ||
<para> | ||
<simplelist> | ||
<member><function>bcceil</function></member> | ||
<member><function>bcround</function></member> | ||
</simplelist> | ||
</para> | ||
</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 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.