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 all commits
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
106 changes: 106 additions & 0 deletions reference/math/functions/fdiv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.fdiv" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>fdiv</refname>
<refpurpose>Divides two numbers, according to IEEE 754</refpurpose>
</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>
<para>
Note that in comparisons, <literal>NAN</literal> will never <code>==</code> or <code>===</code>,
any value, including itself.
</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
var_dump(fdiv(5.7, 1.3)); // float(4.384615384615385)
var_dump(fdiv(4, 2)); // float(2)
var_dump(fdiv(1.0, 0.0)); // float(INF)
var_dump(fdiv(-1.0, 0.0)); // float(-INF)
var_dump(fdiv(0.0, 0.0)); // float(NAN)
?>
]]>
</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 @@ -24,6 +24,7 @@
<function name="exp" from="PHP 4, PHP 5, PHP 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="fdiv" from="PHP 8 &gt;= 8.0"/>
Crell marked this conversation as resolved.
Show resolved Hide resolved
<function name="fmod" from="PHP 4 &gt;= 4.2.0, PHP 5, PHP 7"/>
<function name="getrandmax" from="PHP 4, PHP 5, PHP 7"/>
<function name="hexdec" from="PHP 4, PHP 5, PHP 7"/>
Expand Down