bitstring() complement
[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"
18           xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19           xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20           xmlns:scilab="http://www.scilab.org" xml:id="dec2bin" xml:lang="en">
21     <refnamediv>
22         <refname>dec2bin</refname>
23         <refpurpose>convert from decimal to binary</refpurpose>
24     </refnamediv>
25     <refsynopsisdiv>
26         <title>Syntax</title>
27         <synopsis>
28             str = dec2bin(x)
29             str = dec2bin(x,n)
30         </synopsis>
31     </refsynopsisdiv>
32     <refsection>
33         <title>Arguments</title>
34         <variablelist>
35             <varlistentry>
36                 <term>x</term>
37                 <listitem>
38                     <para>matrix of doubles, positive integer values</para>
39                 </listitem>
40             </varlistentry>
41             <varlistentry>
42                 <term>n</term>
43                 <listitem>
44                     <para>a positive integer</para>
45                 </listitem>
46             </varlistentry>
47             <varlistentry>
48                 <term>str</term>
49                 <listitem>
50                     <para>a matrix of strings</para>
51                 </listitem>
52             </varlistentry>
53         </variablelist>
54     </refsection>
55     <refsection>
56         <title>Description</title>
57         <para>
58             Given <literal>x</literal>, a positive (or a vector/matrix of
59             integers) integer, this function returns a string (or a column vector of
60             strings) which is the binary representation of <literal>x. </literal>If
61             dimension of <literal>x</literal> is superior than 1 then each component
62             of the column vector <literal>str</literal> is the binary representation
63             of the <literal>x</literal> components (i.e <literal>str(i)</literal> is
64             the binary representation of <literal>x(i)</literal>).
65         </para>
66         <para>
67             If the components length of <literal>str</literal> is less than <literal>n</literal> ( i.e
68             length str(i) &lt; n ), then add to <literal>str</literal> components the
69             characters '0' on the left in order to have components length equal to
70             <literal>n.</literal>
71         </para>
72     </refsection>
73     <refsection>
74         <title>Examples</title>
75         <programlisting role="example"><![CDATA[
76 // example 1 :
77 x=86;
78 str=dec2bin(x)
79
80 // example 2 :
81 // The binary representation of 86 is: '1010110'.
82 // Its length is 7 (less than n).
83 // We add to str 8 times the character '0' (on the left).
84 x=86;
85 n=15;
86 str=dec2bin(x,n)
87
88 // example 3 :
89 x=[12;45;135]
90 z=dec2bin(x)
91  ]]></programlisting>
92     </refsection>
93     <refsection role="see also">
94         <title>See also</title>
95         <simplelist type="inline">
96             <member>
97                 <link linkend="bitstring">bitstring</link>
98             </member>
99             <member>
100                 <link linkend="dec2base">dec2base</link>
101             </member>
102             <member>
103                 <link linkend="dec2oct">dec2oct</link>
104             </member>
105             <member>
106                 <link linkend="dec2hex">dec2hex</link>
107             </member>
108             <member>
109                 <link linkend="bin2dec">bin2dec</link>
110             </member>
111         </simplelist>
112     </refsection>
113 </refentry>