* Bug #12335 fixed - strtod didn't work with negative numbers.
[scilab.git] / scilab / modules / string / help / en_US / strtod.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) INRIA - 
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11  *
12  -->
13 <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="strtod" xml:lang="en">
14     <refnamediv>
15         <refname>strtod</refname>
16         <refpurpose>convert string to double</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>
21             d =  strtod(str)
22             [d, endstr] = strtod(str)
23         </synopsis>
24     </refsynopsisdiv>
25     <refsection>
26         <title>Arguments</title>
27         <variablelist>
28             <varlistentry>
29                 <term>str</term>
30                 <listitem>
31                     <para>
32                         a character string or matrix of character strings.
33                     </para>
34                 </listitem>
35             </varlistentry>
36             <varlistentry>
37                 <term>d</term>
38                 <listitem>
39                     <para>
40                         a real or matrix of reals.
41                     </para>
42                 </listitem>
43             </varlistentry>
44             <varlistentry>
45                 <term>endstr</term>
46                 <listitem>
47                     <para>
48                         a character string or matrix of character strings (next
49                         character in <varname>str</varname> after the numerical
50                         value).
51                     </para>
52                 </listitem>
53             </varlistentry>
54         </variablelist>
55     </refsection>
56     <refsection>
57         <title>Description</title>
58         <para>
59             <code>[d, endstr] = strtod(str)</code> parses strings
60             <varname>str</varname> interpreting its content as a floating point
61             number and returns its value as a real. If <varname>str</varname> does not contain any numerical value then <varname>d</varname> equals <literal>Nan</literal>.
62         </para>
63     </refsection>
64     <refsection>
65         <title>Remark</title>
66         <para>
67             This function is based on the strtod C function which causes different behaviors on Windows and Linux. In fact, on Windows, it is possible to use
68             d or D for exponents, but it is not possible to use hexadecimal numbers.
69         </para>
70     </refsection> 
71     <refsection>
72         <title>Examples</title>
73         <programlisting role="example"><![CDATA[ 
74 strtod('123.556This is a sample real')
75 [d,endstr] = strtod('123.556This is a sample real')
76 strtod(['123.556This is a sample real','888.666 here'])
77 [d,endstr] =strtod(['123.556This is a sample real','888.666 here'])
78  ]]></programlisting>
79     </refsection>
80     <refsection>
81         <title>History</title>
82         <revhistory>
83             <revision>
84                 <revnumber>5.4.1</revnumber>
85                 <revremark>If <varname>str</varname> does not contain any numerical value then <varname>d</varname> equals <literal>Nan</literal> instead of <literal>0</literal> in previous versions.</revremark>
86             </revision>
87         </revhistory>
88     </refsection>
89 </refentry>