Update help page of strtod after bug #5073
[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.1-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 [,decimalseparator])
22             [d, endstr] = strtod(str [,decimalseparator])
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>decimalseparator</term>
38                 <listitem>
39                     <para>
40                         the decimal separator chosen: "." (by default) or ",".
41                     </para>
42                 </listitem>
43             </varlistentry>
44             <varlistentry>
45                 <term>d</term>
46                 <listitem>
47                     <para>
48                         a real or matrix of reals.
49                     </para>
50                 </listitem>
51             </varlistentry>
52             <varlistentry>
53                 <term>endstr</term>
54                 <listitem>
55                     <para>
56                         a character string or matrix of character strings (next
57                         character in <varname>str</varname> after the numerical
58                         value).
59                     </para>
60                 </listitem>
61             </varlistentry>
62         </variablelist>
63     </refsection>
64     <refsection>
65         <title>Description</title>
66         <para>
67             <code>[d, endstr] = strtod(str)</code> parses strings
68             <varname>str</varname> interpreting its content as a floating point
69             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>.
70         </para>
71     </refsection>
72     <refsection>
73         <title>Remarks</title>
74         <itemizedlist>
75             <listitem>
76                 <para>
77                     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
78                     d or D for exponents, but it is not possible to use hexadecimal numbers.
79                 </para>
80             </listitem>
81             <listitem>
82                 <para>
83                     Note that <literal>strtod("%inf")</literal> returns <literal>Nan</literal>.
84                 </para>
85             </listitem>
86         </itemizedlist>
87     </refsection>
88     
89     <refsection>
90         <title>Examples</title>
91         <programlisting role="example"><![CDATA[ 
92 strtod('123.556This is a sample real')
93 strtod('123,556This is a sample real', ",")
94 [d,endstr] = strtod('123.556This is a sample real')
95 strtod(['123.556This is a sample real','888.666 here'])
96 [d,endstr] =strtod(['123.556This is a sample real','888.666 here'])
97 [d,endstr] =strtod(['123.556This is a sample real','888,666 here'], ",")
98  ]]></programlisting>
99     </refsection>
100     <refsection>
101         <title>History</title>
102         <revhistory>
103             <revision>
104                 <revnumber>5.5.0</revnumber>
105                 <revremark>
106                     New optional input: decimalseparator (SEP 97).
107                 </revremark>
108             </revision>
109             <revision>
110                 <revnumber>5.4.1</revnumber>
111                 <revremark>
112                     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.
113                 </revremark>
114             </revision>
115         </revhistory>
116     </refsection>
117 </refentry>