Editing
BitwiseOperations
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Bitwise Operations == Bitwise operations are fundamental operations that manipulate individual bits in a binary representation of data. In Elixir, bitwise operations can be performed on integers to perform various tasks, such as extracting specific bits, setting or clearing bits, or performing logical operations. === Bitwise AND === The bitwise AND operation, denoted by the ampersand (&) symbol, compares corresponding bits of two integers and returns a new integer with the bits set to 1 only if both bits are 1. === Bitwise OR === The bitwise OR operation, denoted by the vertical bar (|) symbol, compares corresponding bits of two integers and returns a new integer with the bits set to 1 if either of the corresponding bits is 1. === Bitwise XOR === The bitwise XOR (exclusive OR) operation, denoted by the caret (^) symbol, compares corresponding bits of two integers and returns a new integer with the bits set to 1 if the corresponding bits differ. === Bitwise NOT === The bitwise NOT operation, denoted by the tilde (~) symbol, flips the bits of the integer. Each 0 bit becomes 1, and each 1 bit becomes 0. === Left Shift === The left shift operation, denoted by the double less than (<<) symbol, shifts the bits of an integer to the left by a specified number of positions. === Right Shift === The right shift operation, denoted by the double greater than (>>) symbol, shifts the bits of an integer to the right by a specified number of positions. === Examples === * Bitwise AND example: {{code|1 band 3}} * Bitwise OR example: {{code|1 bor 3}} * Bitwise XOR example: {{code|1 bxor 3}} * Bitwise NOT example: {{code|bnot 1}} * Left shift example: {{code|1 << 2}} * Right shift example: {{code|4 >> 1}} == See Also == * [[LogicOperations]] - Introduction to logical operations in Elixir. * [[BinaryManipulation]] - Manipulating binary data in Elixir. * [[BitwiseOperationsInOtherLanguages]] - Comparison of bitwise operations in other programming languages. == References == <references /> [[Category:Elixir Programming Language]] [[Category:Operations]]
Summary:
Please note that all contributions to Elixir Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Elixir Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Template:Code
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information