Bitwise

This module provide macros and operators for bitwise operators. These macros can be used in guards.

The easiest way to use is to simply import them into your module:

iex> use Bitwise
iex> bnot 1
-2
iex> 1 &&& 1
1

You can select to include only or skip operators by passing options:

iex> use Bitwise, only_operators: true
...> 1 &&& 1
1
Source

Summary

left &&& right

Bitwise and as operator

left <<< right

Arithmetic bitshift left as operator

left >>> right

Arithmetic bitshift right as operator

left ^^^ right

Bitwise xor as operator

__using__(options)

Allow a developer to use this module in their programs with the following options:

band(left, right)

Bitwise and

bnot(expr)

Bitwise not

bor(left, right)

Bitwise or

bsl(left, right)

Arithmetic bitshift left

bsr(left, right)

Arithmetic bitshift right

bxor(left, right)

Bitwise xor

left ||| right

Bitwise or as operator

~~~expr

Bitwise not as operator

Macros

left &&& right

Bitwise and as operator.

Source
left <<< right

Arithmetic bitshift left as operator.

Source
left >>> right

Arithmetic bitshift right as operator.

Source
left ^^^ right

Bitwise xor as operator.

Source
__using__(options)

Allow a developer to use this module in their programs with the following options:

  • :only_operators - Include only operators;
  • :skip_operators - Skip operators;
Source
band(left, right)

Bitwise and.

Source
bnot(expr)

Bitwise not.

Source
bor(left, right)

Bitwise or.

Source
bsl(left, right)

Arithmetic bitshift left.

Source
bsr(left, right)

Arithmetic bitshift right.

Source
bxor(left, right)

Bitwise xor.

Source
left ||| right

Bitwise or as operator.

Source
~~~expr

Bitwise not as operator.

Source