
- Erlang Tutorial
- Erlang - Home
- Erlang - Overview
- Erlang - Environment
- Erlang - Basic Syntax
- Erlang - Shell
- Erlang - Data Types
- Erlang - Variables
- Erlang - Operators
- Erlang - Loops
- Erlang - Decision Making
- Erlang - Functions
- Erlang - Modules
- Erlang - Recursion
- Erlang - Numbers
- Erlang - Strings
- Erlang - Lists
- Erlang - File I/O
- Erlang - Atoms
- Erlang - Maps
- Erlang - Tuples
- Erlang - Records
- Erlang - Exceptions
- Erlang - Macros
- Erlang - Header Files
- Erlang - Preprocessors
- Erlang - Pattern Matching
- Erlang - Guards
- Erlang - BIFS
- Erlang - Binaries
- Erlang - Funs
- Erlang - Processes
- Erlang - Emails
- Erlang - Databases
- Erlang - Ports
- Erlang - Distributed Programming
- Erlang - OTP
- Erlang - Concurrency
- Erlang - Performance
- Erlang - Drivers
- Erlang - Web Programming
- Erlang Useful Resources
- Erlang - Quick Guide
- Erlang - Useful Resources
- Erlang - Discussion
Erlang - Bitwise Operators
Following are the bitwise operators available in Erlang.
Sr.No. | Operator & Description |
---|---|
1 |
band This is the bitwise “and” operator |
2 |
bor This is the bitwise “or” operator |
3 |
bxor This is the bitwise “xor” or Exclusive or operator |
4 |
bnot This is the bitwise negation operator |
Following is the truth table showcasing 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 snippet shows how the various operators can be used.
Example
-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 −
Output
76 0 -111101 111100
erlang_operators.htm
Advertisements