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" 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">
19 <refname>dec2bin</refname>
20 <refpurpose>convert from decimal to binary</refpurpose>
30 <title>Arguments</title>
35 <para>matrix of doubles, positive integer values</para>
41 <para>a positive integer</para>
47 <para>a matrix of strings</para>
53 <title>Description</title>
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>).
64 If the components length of <literal>str</literal> is less than <literal>n</literal> ( i.e
65 length str(i) < n ), then add to <literal>str</literal> components the
66 characters '0' on the left in order to have components length equal to
71 <title>Examples</title>
72 <programlisting role="example"><![CDATA[
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).
90 <refsection role="see also">
91 <title>See also</title>
92 <simplelist type="inline">
94 <link linkend="base2dec">base2dec</link>
97 <link linkend="bin2dec">bin2dec</link>
100 <link linkend="oct2dec">oct2dec</link>
103 <link linkend="hex2dec">hex2dec</link>
106 <link linkend="dec2oct">dec2oct</link>
109 <link linkend="dec2hex">dec2hex</link>