d359cded98a6a73f8924d2ca403999df1537b6be
[scilab.git] / scilab / modules / elementary_functions / help / en_US / integer_representation / dec2bin.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) 2008 - INRIA
5  * Copyright (C) 2011 - DIGITEO - Michael Baudin
6  *
7  * Copyright (C) 2012 - 2016 - Scilab Enterprises
8  *
9  * This file is hereby licensed under the terms of the GNU GPL v2.0,
10  * pursuant to article 5.3.4 of the CeCILL v.2.1.
11  * This file was originally licensed under the terms of the CeCILL v2.1,
12  * and continues to be available under such terms.
13  * For more information, see the COPYING file which you should have received
14  * along with this program.
15  *
16  -->
17 <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="dec2bin" xml:lang="en">
18     <refnamediv>
19         <refname>dec2bin</refname>
20         <refpurpose>convert from decimal to binary</refpurpose>
21     </refnamediv>
22     <refsynopsisdiv>
23         <title>Syntax</title>
24         <synopsis>
25             str=dec2bin(x)
26             str=dec2bin(x,n)
27         </synopsis>
28     </refsynopsisdiv>
29     <refsection>
30         <title>Arguments</title>
31         <variablelist>
32             <varlistentry>
33                 <term>x</term>
34                 <listitem>
35                     <para>matrix of doubles, positive integer values</para>
36                 </listitem>
37             </varlistentry>
38             <varlistentry>
39                 <term>n</term>
40                 <listitem>
41                     <para>a positive integer</para>
42                 </listitem>
43             </varlistentry>
44             <varlistentry>
45                 <term>str</term>
46                 <listitem>
47                     <para>a matrix of strings</para>
48                 </listitem>
49             </varlistentry>
50         </variablelist>
51     </refsection>
52     <refsection>
53         <title>Description</title>
54         <para>
55             Given <literal>x</literal>, a positive (or a vector/matrix of
56             integers) integer, this function returns a string (or a column vector of
57             strings) which is the binary representation of <literal>x. </literal>If
58             dimension of <literal>x</literal> is superior than 1 then each component
59             of the column vector <literal>str</literal> is the binary representation
60             of the <literal>x</literal> components (i.e <literal>str(i)</literal> is
61             the binary representation of <literal>x(i)</literal>).
62         </para>
63         <para>
64             If the components length of <literal>str</literal> is less than <literal>n</literal> ( i.e
65             length str(i) &lt; n ), then add to <literal>str</literal> components the
66             characters '0' on the left in order to have components length equal to
67             <literal>n.</literal>
68         </para>
69     </refsection>
70     <refsection>
71         <title>Examples</title>
72         <programlisting role="example"><![CDATA[
73 // example 1 :
74 x=86;
75 str=dec2bin(x)
76
77 // example 2 :
78 // The binary representation of 86 is: '1010110'.
79 // Its length is 7 (less than n).
80 // We add to str 8 times the character '0' (on the left).
81 x=86;
82 n=15;
83 str=dec2bin(x,n)
84
85 // example 3 :
86 x=[12;45;135]
87 z=dec2bin(x)
88  ]]></programlisting>
89     </refsection>
90     <refsection role="see also">
91         <title>See also</title>
92         <simplelist type="inline">
93             <member>
94                 <link linkend="base2dec">base2dec</link>
95             </member>
96             <member>
97                 <link linkend="bin2dec">bin2dec</link>
98             </member>
99             <member>
100                 <link linkend="oct2dec">oct2dec</link>
101             </member>
102             <member>
103                 <link linkend="hex2dec">hex2dec</link>
104             </member>
105             <member>
106                 <link linkend="dec2oct">dec2oct</link>
107             </member>
108             <member>
109                 <link linkend="dec2hex">dec2hex</link>
110             </member>
111         </simplelist>
112     </refsection>
113 </refentry>