Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fdiv() #258

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions reference/math/functions/fdiv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.fdiv" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>fdiv</refname>
<refpurpose>Returns the division of two numbers</refpurpose>
Crell marked this conversation as resolved.
Show resolved Hide resolved
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>float</type><methodname>fdiv</methodname>
<methodparam><type>float</type><parameter>dividend</parameter></methodparam>
<methodparam><type>float</type><parameter>divisor</parameter></methodparam>
</methodsynopsis>
<para>
Returns the floating point result of dividing the
<parameter>dividend</parameter> by the <parameter>divisor</parameter>.
If the <parameter>divisor</parameter> is zero, then one of <literal>INF</literal>,
<literal>-INF</literal>, or <literal>NAN</literal> will be returned.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>dividend</parameter></term>
<listitem>
<para>
The dividend (numerator)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>divisor</parameter></term>
<listitem>
<para>
The divisor
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The floating point result of
<parameter>dividend</parameter>/<parameter>divisor</parameter>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Using <function>fdiv</function></title>
<programlisting role="php">
<![CDATA[
<?php
$x = 5.7;
$y = 1.3;
$r = fdiv($x, $y);
// $r equals 4.384615384615385
?>
]]>
</programlisting>
</example>
<example>
<title>Using <function>fdiv</function> with possible zero divisor</title>
<programlisting role="php">
<![CDATA[
<?php
$result = match($res = fdiv(5, $user_data)) {
INF, -INF, NAN => 0, // This may be correct in context, or throw an exception.
default => $res,
};
Crell marked this conversation as resolved.
Show resolved Hide resolved
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="language.operators.arithmetic"><literal>/</literal></link> - Floating-point division</member>
<member><function>intdiv</function> - Integer division</member>
<member><function>fmod</function> - Modulus</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
-->
1 change: 1 addition & 0 deletions reference/math/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<function name="expm1" from="PHP 4 &gt;= 4.1.0, PHP 5, PHP 7"/>
<function name="floor" from="PHP 4, PHP 5, PHP 7"/>
<function name="fmod" from="PHP 4 &gt;= 4.2.0, PHP 5, PHP 7"/>
<function name="fdiv" from="PHP 8 &gt;= 8.0"/>
Crell marked this conversation as resolved.
Show resolved Hide resolved
<function name="getrandmax" from="PHP 4, PHP 5, PHP 7"/>
<function name="hexdec" from="PHP 4, PHP 5, PHP 7"/>
<function name="hypot" from="PHP 4 &gt;= 4.1.0, PHP 5, PHP 7"/>
Expand Down