1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
5 * Copyright (C) 2011 - DIGITEO - Michael Baudin
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
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.
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">
22 <refname>dec2bin</refname>
23 <refpurpose>convert from decimal to binary</refpurpose>
33 <title>Arguments</title>
38 <para>matrix of doubles, positive integer values</para>
44 <para>a positive integer</para>
50 <para>a matrix of strings</para>
56 <title>Description</title>
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>).
67 If the components length of <literal>str</literal> is less than <literal>n</literal> ( i.e
68 length str(i) < n ), then add to <literal>str</literal> components the
69 characters '0' on the left in order to have components length equal to
74 <title>Examples</title>
75 <programlisting role="example"><![CDATA[
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).
93 <refsection role="see also">
94 <title>See also</title>
95 <simplelist type="inline">
97 <link linkend="bitstring">bitstring</link>
100 <link linkend="dec2base">dec2base</link>
103 <link linkend="dec2oct">dec2oct</link>
106 <link linkend="dec2hex">dec2hex</link>
109 <link linkend="bin2dec">bin2dec</link>