# Bitwise operator "&" won't work in kernel functions

**URL:** <https://discourse.julialang.org/t/bitwise-operator-wont-work-in-kernel-functions/93159>\
**Category:** GPU\
**Created:** [January 18, 2023, 2:19pm UTC](https://discourse.julialang.org/t/bitwise-operator-wont-work-in-kernel-functions/93159 "2023-01-18T14:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zero/32/44847_2.png) [@zero](https://discourse.julialang.org/u/zero)\
**Post date:** [January 18, 2023, 2:19pm UTC](https://discourse.julialang.org/t/bitwise-operator-wont-work-in-kernel-functions/93159/1 "2023-01-18T14:19:43Z")

</div>

Hi everyone,

CUDA does not have an intrinsic function to operate “&”. However, in c/c++ you can still use the intrinsic bitwise \_\_and() to get the same result in your kernel method, or in python for example by cupy you can [this](https://docs.cupy.dev/en/stable/reference/generated/cupy.bitwise_and.html).  
In Julia, it is not possible to does bitwise “&” in kernel functions, So no CUDA version and no Julia version. Any idea? Suggestion?

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [January 18, 2023, 3:33pm UTC](https://discourse.julialang.org/t/bitwise-operator-wont-work-in-kernel-functions/93159/2 "2023-01-18T15:33:54Z")

</div>

Are you sure it doesn’t just work already?

```julia
using CUDA
x = CuArray(rand(Bool, 10, 10))
y = CuArray(rand(Bool, 10, 10))
x .& y

```

Gives me:

```julia
julia> x .& y
10×10 CuArray{Bool, 2, CUDA.Mem.DeviceBuffer}:
 0 0 0 0 0 0 1 1 0 0
 0 0 0 0 0 1 0 1 1 0
 1 0 0 1 0 0 0 0 0 0
 1 0 0 0 0 1 0 1 0 0
 0 0 1 0 0 1 0 0 0 0
 0 1 1 0 1 0 0 0 1 0
 0 0 0 0 0 1 0 0 0 0
 1 0 0 1 0 1 1 1 1 0
 0 0 0 0 0 0 0 0 0 0
 1 1 0 0 1 0 0 1 1 0

```

---

<div class="post-metadata">

**Author:** ![zero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zero/32/44847_2.png) [@zero](https://discourse.julialang.org/u/zero)\
**Post date:** [February 23, 2023, 2:26pm UTC](https://discourse.julialang.org/t/bitwise-operator-wont-work-in-kernel-functions/93159/3 "2023-02-23T14:26:56Z")

</div>

Actually it works, Thank you very much.
