ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

Bitwise Operator

Definition - What does Bitwise Operator mean?

A bitwise operator is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits.

Bitwise operators are used in:

  • Communication stacks where the individual bits in the header attached to the data signify important information
  • Embedded software for controlling different functions in the chip and indicating the status of hardware by manipulating the individual bits of hardware registers of embedded microcontrollers
  • Low-level programming for applications such as device drivers, cryptographic software, video decoding software, memory allocators, compression software and graphics
  • Maintaining large sets of integers efficiently in search and optimization problems
  • Bitwise operations performed on bit flags, which can enable an instance of enumeration type to store any combination of values defined in an enumerator list

Techopedia explains Bitwise Operator

Unlike common logical operators (like +, -, *), which work with bytes or groups of bytes, bitwise operators can check or set each of the individual bits within a byte. Bitwise operators never cause overflow because the result produced after the bitwise operation is within the range of possible values for the numeric type involved.

The bitwise operators used in the C family of languages (C#, C and C++) are:

  • OR (|): Result is true if any of the operands is true.
  • AND (&): Result is true only if both operands are true. It can be used to set up a mask to check the values of certain bits.
  • XOR (^): Result is true only if one of its operands is true. It is used mainly to toggle certain bits. It also helps to swap two variables without using a third one.
  • Bitwise Complement or Inversion or NOT (~): Provides the bitwise complement of an operand by inverting its value such that all zeros are turned into ones and all ones are turned to zeros.
  • >> (Right-Shift) and << (Left-Shift) Operator: Moves the bits the number of positions specified by the second operand in the right or left direction. While the right-shift operation is an arithmetic shift for operands of type int or long, it is a logical shift for operands of type uint or ulong. Shift operators are used in aligning bits.

The order of precedence (from highest to lowest) in bitwise operators is:

  1. ~
  2. << and >>
  3. &
  4. ^
  5. |
This definition was written in the context of General Programming

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.