# xarray.ufuncs.bitwise_xor

### xarray.ufuncs.bitwise_xor *= <xarray.ufuncs._binary_ufunc object>*

xarray specific variant of `numpy.bitwise_xor()`. Handles xarray objects by dispatching to the appropriate function for the underlying array type.

Documentation from numpy:

Compute the bit-wise XOR of two arrays element-wise.

Computes the bit-wise XOR of the underlying binary representation of
the integers in the input arrays. This ufunc implements the C/Python
operator `^`.

* **Parameters:**
  * **x1, x2** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like)) – Only integer and boolean types are handled.
    If `x1.shape != x2.shape`, they must be broadcastable to a common
    shape (which becomes the shape of the output).
  * **out** ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), [`None`](https://docs.python.org/3/builtins/constants.html#None), or [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) of [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) and [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – A location into which the result is stored. If provided, it must have
    a shape that the inputs broadcast to. If not provided or None,
    a freshly-allocated array is returned. A tuple (possible only as a
    keyword argument) must have length equal to the number of outputs.
  * **where** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like), *optional*) – This condition is broadcast over the input. At locations where the
    condition is True, the out array will be set to the ufunc result.
    Elsewhere, the out array will retain its original value.
    Note that if an uninitialized out array is created via the default
    `out=None`, locations within it where the condition is False will
    remain uninitialized.
  * **\*\*kwargs** – For other keyword-only arguments, see the
    [ufunc docs](https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs).
* **Returns:**
  **out** ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) or [scalar](../user-guide/terminology.html.md#term-scalar)) – Result.
  This is a scalar if both x1 and x2 are scalars.

#### SEE ALSO
[`logical_xor`](xarray.ufuncs.logical_xor.html.md#xarray.ufuncs.logical_xor), [`bitwise_and`](xarray.ufuncs.bitwise_and.html.md#xarray.ufuncs.bitwise_and), [`bitwise_or`](xarray.ufuncs.bitwise_or.html.md#xarray.ufuncs.bitwise_or)

`binary_repr`
: Return the binary representation of the input number as a string.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('75dc68fa-19bc-4809-9ae1-18a99ef9619a','eee05847-8c82-4843-b5f7-7f2677ca2d7d','dec9f929-d161-4579-a187-ff371f3530ca','../lite/tree/../notebooks/index.html?path=f03fee2b_45a6_4a4c_abc4_33504fd07030.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import numpy as np
```

The number 13 is represented by `00001101`. Likewise, 17 is
represented by `00010001`.  The bit-wise XOR of 13 and 17 is
therefore `00011100`, or 28:

```pycon
>>> np.bitwise_xor(13, 17)
28
>>> np.binary_repr(28)
'11100'
```

```pycon
>>> np.bitwise_xor(31, 5)
26
>>> np.bitwise_xor([31,3], 5)
array([26,  6])
```

```pycon
>>> np.bitwise_xor([31,3], [5,6])
array([26,  5])
>>> np.bitwise_xor([True, True], [False, True])
array([ True, False])
```

The `^` operator can be used as a shorthand for `np.bitwise_xor` on
ndarrays.

```pycon
>>> x1 = np.array([True, True])
>>> x2 = np.array([False, True])
>>> x1 ^ x2
array([ True, False])
```

<div id="dec9f929-d161-4579-a187-ff371f3530ca" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('75dc68fa-19bc-4809-9ae1-18a99ef9619a','dec9f929-d161-4579-a187-ff371f3530ca')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('75dc68fa-19bc-4809-9ae1-18a99ef9619a','dec9f929-d161-4579-a187-ff371f3530ca')">Open In Tab</button></div><div id="eee05847-8c82-4843-b5f7-7f2677ca2d7d" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
