Bit Shifting

Definition - What does Bit Shifting mean?

Bit shifting is an operation done on all the bits of a binary value in which they are moved by a determined number of places to either the left or right. Bit shifting is used when the operand is being used as a series of bits rather than as a whole. In other words, the operand is treated as individual bits that stand for something and not as a value.

Bit shifting is often used in programming and has at least one variation in each programming language.

Bit shifting may also be known as a bitwise operation

Techopedia explains Bit Shifting

There are two variations to bit shifting, shift right and shift left, and it is further defined by the number of places in which the shift should occur. For example, shifting the operand one value to the left or shifting the bits "n" values to the right.

There are also two kinds of bit shifting, logical and arithmetic. Logical bit shifting may be useful for multiplying or dividing unsigned integers by powers of two. For example, if the value "0001" or "1" is shifted left, it becomes "0010" or "2", shifted to the left again it becomes "0100," or "4". Shifting to the right has an opposite effect of dividing the value by two per shift. In most cases, shifting is treated as circular so when shifting to the left, the leftmost value becomes the rightmost value, and vice versa.

Logical left shift and arithmetic left shift have the same effect so Java only has a single left shift operator (<<). The arithmetic right shift is (>>) while the logical is (>>>). In C and C++, there is only one shift right operator (>>); the kind of shift to be done is determined by the type of integer being shifted. Signed integers are shifted using arithmetic while logical bit shifting is used on unsigned integers. Bit shifting is also used a lot in assembly programming because microcontrollers and microprocessors usually rely on flags, which are represented by individual bits. Basically, it's because the binary number system is used in programming in assembly language that bit shifting becomes a commonly used operator.
Share this:

Connect with us

Email Newsletter

Join thousands of others with our weekly newsletter

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.