English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The following are the bitwise operators available in Erlang.
S.No. | Operator & Description |
---|---|
1 | band Bitwise 'and' operator |
2 | bor Bitwise 'or' operator |
3 | bxor Bitwise 'xor' or exclusive OR operator |
4 | bnot Bitwise NOT operator |
The following is the truth table for these operators-
p | q | p & q | p | q | p ^ q |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 0 |
1 | 0 | 0 | 1 | 1 |
The following code block shows how to use various operators.
-module(helloworld). -export([start/0]). start() -> io:fwrite("~w~n",[00111100 band 00001101]), io:fwrite("~w~n",[00111100 bxor 00111100]), io:fwrite("~w~n",[bnot 00111100]), io:fwrite("~w~n",[00111100 bor 00111100]).
The output of the above program will be:
76 0 -111101 111100