da86375400133f2bbf5513abe46a234e4e02e5e5
[scilab.git] / scilab / modules / elementary_functions / help / en_US / bitwise / bitxor.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  *
4  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
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:ns3="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="bitxor" xml:lang="en">
18     <refnamediv>
19         <refname>bitxor</refname>
20         <refpurpose>bitwise XOR</refpurpose>
21     </refnamediv>
22     <refsynopsisdiv>
23         <title>Syntax</title>
24         <synopsis>
25             z = bitxor(x, y)
26         </synopsis>
27     </refsynopsisdiv>
28     <refsection>
29         <title>Parameters</title>
30         <variablelist>
31             <varlistentry>
32                 <term>x :</term>
33                 <listitem>
34                     <para>
35                         a <literal>m</literal>-by-<literal>n</literal> matrix of doubles
36                         or a <literal>m1</literal>-by-<literal>m2</literal>-by-...-by-<literal>mm</literal> hypermatrix of doubles
37                         or a <literal>m</literal>-by-<literal>n</literal> matrix of unsigned integers (<literal>uint8</literal>, <literal>uint16</literal> or <literal>uint32</literal>).
38                         Must contain positive integer values.
39                     </para>
40                 </listitem>
41             </varlistentry>
42             <varlistentry>
43                 <term>y :</term>
44                 <listitem>
45                     <para>
46                         a <literal>m</literal>-by-<literal>n</literal> matrix of doubles
47                         or a <literal>m1</literal>-by-<literal>m2</literal>-by-...-by-<literal>mm</literal> hypermatrix of doubles
48                         or a <literal>m</literal>-by-<literal>n</literal> matrix of unsigned integers (<literal>uint8</literal>, <literal>uint16</literal> or <literal>uint32</literal>).
49                         Must contain positive integer values.
50                     </para>
51                 </listitem>
52             </varlistentry>
53             <varlistentry>
54                 <term>z :</term>
55                 <listitem>
56                     <para>
57                         a <literal>m</literal>-by-<literal>n</literal> matrix of doubles
58                         or a <literal>m1</literal>-by-<literal>m2</literal>-by-...-by-<literal>mm</literal> hypermatrix of doubles
59                         or a <literal>m</literal>-by-<literal>n</literal> matrix of unsigned integers.
60                     </para>
61                 </listitem>
62             </varlistentry>
63         </variablelist>
64     </refsection>
65     <refsection>
66         <title>Description</title>
67         <para>
68             Given <varname>x</varname> and <varname>y</varname> two positive integers, this function returns the decimal
69             number <varname>z</varname> whose the binary form is the XOR of the binary representations
70             of <varname>x</varname> and <varname>y</varname>.
71         </para>
72         <para>
73         </para>
74     </refsection>
75     <refsection>
76         <title>Examples</title>
77         <programlisting role="example"><![CDATA[
78 // Compute the bitwise XOR of two matrices of doubles.
79 x = [0 1 0 1];
80 y = [0 0 1 1];
81 z = bitxor(x, y)
82 expected = [0 1 1 0];
83
84 // Compute the bitwise XOR of two matrices of integers.
85 x = uint8([0 1 0 1]);
86 y = uint8([0 0 1 1]);
87 z = bitxor(x, y)
88
89 // The types of x and y cannot be mixed (error).
90 x = [0 1 0 1];
91 y = uint8([0 0 1 1]);
92 // z = bitxor(x, y)
93
94 //  13 is (01101)_2
95 //  27 is (11011)_2
96 // XOR is (10110)_2 which is 22.
97 bitxor(uint8(13), uint8(27))
98 bitxor(13, 27)
99
100    ]]></programlisting>
101     </refsection>
102 </refentry>