Bitwise Operators in PHP ?

beingchinmay

New member
The bitwise operators act on the binary representation of their operands. Each operand is first turned into a binary representation of the value, as described in the bitwise negation operator entry in the following list. All the bitwise operators work on numbers as well as strings, but they vary in their treatment of string operands of different
lengths. The bitwise operators are:

Bitwise negation (~)

The bitwise negation operator changes 1s to 0s and 0s to 1s in the binary representations of the operands. Floating-point values are converted to integers before the operation takes place. If the operand is a string, the resulting value is a string the same length as the original, with each character in the string negated.

Bitwise AND (&)

The bitwise AND operator compares each corresponding bit in the binary representations of the operands. If both bits are 1, the corresponding bit in the result is 1; otherwise, the corresponding bit is 0. For example, 0755 & 0671 is 0651. This is a bit easier to understand if we look at the binary representation.
 
Bitwise operators allow evaluation and manipulation of specific bits with in an integer...
Bitwise operators are Bitwise AND (&) , Bitwise OR(/) and Bitwise negation (~).
 
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
 
Last edited:
Bitwise Operators are the operators that are used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits.
The bitwise operators are listed below
‘ &’ — Binary AND Operator
‘ | ’ — Binary OR Operator
‘ ^ ’ — Binary XOR Operator
‘ ~ ’ — Binary NOT Operator
 
Back
Top