<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA
 * Copyright (C) 2017 - Samuel GOUGEON
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
          xmlns:scilab="http://www.scilab.org" xml:id="ieee" xml:lang="en">
    <refnamediv>
        <refname>ieee</refname>
        <refpurpose>sets or gets the floating point exception mode</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>mod = ieee()
            ieee(mod)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>mod</term>
                <listitem>
                    <para>integer scalar whose possible values are 0, 1 or 2</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <literal>ieee()</literal> returns the current floating point exception mode.
        <variablelist>
            <varlistentry>
                <term>0</term>
                <listitem>
                    <para>floating point exception produces an error.</para>
                    <para>
                       <literal>%inf</literal> and <literal>%nan</literal> special values can be
                       used in this mode without error. For instance, <literal>%inf/%inf</literal>,
                       <literal>%inf-%inf</literal> or <literal>%inf/%nan</literal> are known
                       operations.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>1</term>
                <listitem>
                    floating point exception produces a warning.
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>2</term>
                <listitem>
                    floating point exception produces Inf or Nan.
                </listitem>
            </varlistentry>
        </variablelist>
        </para>
        <para>
            <literal>ieee(mod)</literal> sets the current floating point exception mode to
            <varname>mod</varname>.
        </para>
        <note>
            The default initial mode is 2. This default value may be set in any of the following ways:
            <itemizedlist>
                <listitem>
                  Through the Preferences GUI: <code>preferences</code>, in the section
                  <emphasis role="italic">General => Environment => ieee</emphasis>.
                </listitem>
                <listitem>
                  Equivalently, using <code>xmlSetValues</code> as follows
                  (to set the mode to 1) :
                  <para>
                  <literal>xmlSetValues("//general/body/environment", ["fpe";"1"])</literal>
                  </para>
                </listitem>
                <listitem>
                    Or by using <literal>ieee(mod)</literal> in your startup file.
                </listitem>
            </itemizedlist>
        </note>
        <warning>
            Floating point exception arising inside some library algorithms are not yet handled
            by <literal>ieee</literal> modes.
        </warning>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
ieee(1); 1/0
ieee(2); 1/0, log(0)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See Also</title>
        <simplelist type="inline">
            <member>
                <link linkend="percentnan">%nan</link>
            </member>
            <member>
                <link linkend="percentinf">%inf</link>
            </member>
            <member>
                <link linkend="isinf">isinf</link>
            </member>
             <member>
                <link linkend="isnan">isnan</link>
            </member>
           <member>
                <link linkend="number_properties">number_properties</link>
            </member>
        </simplelist>
    </refsection>
    <refsection role="history">
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>6.0.0</revnumber>
                <revremark>2 is now the initial mode value.</revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>
