<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.is-nan" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>is_nan</refname>
  <refpurpose>Checks whether a float is NAN</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>is_nan</methodname>
   <methodparam><type>float</type><parameter>num</parameter></methodparam>
  </methodsynopsis>
  <para>
   Returns whether the given <parameter>num</parameter> is <literal>NAN</literal> (<quote>Not A Number</quote>).
  </para>
  <para>
   <literal>NAN</literal> is returned from mathematical operations that are undefined,
   for example when passing parameters outside of function’s input domain. The square root
   (<function>sqrt</function>) is only defined for positive numbers, passing a negative number
   will result in <literal>NAN</literal>. Other examples of operations returning <literal>NAN</literal>
   are dividing <literal>INF</literal> by <literal>INF</literal> and any operation involving an
   existing <literal>NAN</literal> value.
  </para>
  <note>
   <para>
    Despite its name of <quote>Not A Number</quote>, <literal>NAN</literal> is a valid value of type &float;.
   </para>
  </note>
  <caution>
   <para>
    <literal>NAN</literal> does not compare equal to <literal>NAN</literal>. To check whether
    a float is <literal>NAN</literal>, <function>is_nan</function> must be used. Checking
    <code>$float === NAN</code> will not work.
   </para>
  </caution>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>num</parameter></term>
     <listitem>
      <para>
       The &float; to check
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &true; if <parameter>num</parameter> is <literal>NAN</literal>, else &false;.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>is_nan</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$nan = sqrt(-1);

var_dump($nan, is_nan($nan));
?>
]]>
    </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
float(NAN)
bool(true)
]]>
    </screen>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>is_finite</function></member>
    <member><function>is_infinite</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
-->
