Julia Bitwise Operators

In this Julia Tutorial, we will learn about Julia Bitwise Operators.

The following table lists available bitwise operators in Julia.

ExpressionName
~xbitwise not
x & ybitwise and
x | ybitwise or
x ? ybitwise xor (exclusive or)
x >>> ylogical shift right
x >> yarithmetic shift right
x << ylogical/arithmetic shift left

Bitwise NOT

julia> x = 10
10

julia> ~x
-11

Bitwise AND

julia> x = 10
10

julia> y = 25
25

julia> x & y
8

Bitwise OR

julia> x = 10
10

julia> y = 25
25

julia> x | y
27

Bitwise XOR

julia> x = 10
10

julia> y = 25
25

julia> x ? y
19

Logical Shift Right

julia> x = 25
25

julia> x >>> 2
6

Arithmetic Shift Right

julia> x = 25
25

julia> x >> 2
6

Logical/Arithmetic Shift Left

julia> x = 25
25

julia> x << 1
50

Conclusion

In this Julia Tutorial, we learned Julia Bitwise Operators and how to use them with examples.