Bitwise operations

Bitwise operations are logic operations that act on each bit of a binary number one at a time. In Intro to Electrical Engineering, you use them to mask, shift, toggle, and compare digital values.

Last updated July 2026

What are bitwise operations?

Bitwise operations are the rules digital systems use to manipulate binary data one bit at a time. In Intro to Electrical Engineering, that means you are not treating a number as a whole decimal value, you are changing the 0s and 1s inside its binary form.

The main bitwise operations are AND, OR, XOR, NOT, and shift operations. AND keeps a bit as 1 only when both input bits are 1. OR makes a bit 1 when either input bit is 1. XOR makes a bit 1 when the two input bits differ, which is why it is often used for toggling. NOT flips every bit, turning 0 into 1 and 1 into 0.

These operations matter because digital hardware is built from logic gates that behave this way. When you combine bits with a mask, you can isolate part of a number, clear selected bits, or force a bit pattern you want. That is why bitwise logic shows up in microcontroller registers, digital control signals, and low-level circuit work.

Shift operations move every bit left or right. A left shift usually multiplies by powers of 2 in binary, while a right shift usually divides by powers of 2 if you are working with unsigned values. In class problems, this often shows up when you are converting binary patterns, setting flag bits, or checking how a register changes after a logic step.

A quick example: if you AND 101101 with 000111, you get 000101. The mask keeps only the last three bits and clears the rest. That is the basic move behind filtering data, checking status bits, and reading a digital value from a larger binary word.

Why bitwise operations matter in Intro to Electrical Engineering

Bitwise operations connect binary number systems to the actual behavior of digital circuits. Once you know how they work, you can read logic expressions, predict register values, and explain why a circuit output changes when one input bit changes.

They also make masking and shifting feel less random. A mask is just a chosen bit pattern, and bitwise AND, OR, and XOR let you combine that pattern with data in a controlled way. In a microcontroller setting, that can mean turning one output pin on, clearing a status flag, or checking whether a sensor bit is set.

This term also shows up in binary arithmetic and digital logic units. If a problem asks you to inspect a binary word, apply a mask, or trace a shift, you are using bitwise operations whether the question says so directly or not. They are one of the fastest ways to describe what a circuit or processor is doing at the bit level.

For this course, bitwise operations are the bridge between abstract binary notation and practical hardware behavior. They turn a list of 0s and 1s into a tool for analysis.

Keep studying Intro to Electrical Engineering Unit 13

How bitwise operations connect across the course

Binary

Bitwise operations only make sense when you are working in binary, because each operation compares individual bits. If you are comfortable reading binary place values, it becomes much easier to see why AND keeps some bits, XOR flips selected bits, and shifts move values across positions.

Masking

Masking is one of the most common uses of bitwise logic. You apply a binary mask with AND, OR, or XOR to keep certain bits, clear them, or change them without touching the rest of the word. In labs, this often shows up when you work with registers or control bits.

Shift Operations

Shift operations change the position of bits instead of comparing them. They are closely related to bitwise work because they are another way to manipulate a binary pattern directly. In many problems, a shift is the next step after masking or a shortcut for multiplying or dividing by powers of 2.

binary addition

Binary addition uses carries, while bitwise logic follows gate rules bit by bit. The two topics overlap in digital systems because adders are built from logic circuits, but they answer different questions. If a problem asks for a sum, use addition rules. If it asks to compare or alter bits, use bitwise operations.

Are bitwise operations on the Intro to Electrical Engineering exam?

A quiz question or problem set item will usually give you two binary values and ask you to apply AND, OR, XOR, NOT, or a shift. Your job is to work bit by bit, not convert everything to decimal unless the question asks you to. Watch for masks, because many questions hide a simple filtering step inside a larger binary word.

You may also see a register, flag, or output pattern and need to trace what happens after one logic operation. The fastest method is to line up the bits, apply the rule in each column, and keep track of where a 1 is preserved, cleared, or toggled. A common mistake is treating XOR like OR. XOR gives 1 only when the bits are different, so equal bits become 0.

Bitwise operations vs binary addition

Binary addition combines numbers with carries, so it changes place values based on arithmetic rules. Bitwise operations do not add the numbers together. They compare or move the individual bits themselves, which is why XOR or AND can give a result that looks nothing like a sum.

Key things to remember about bitwise operations

  • Bitwise operations act on individual binary digits, not on a number as a whole.

  • AND, OR, XOR, and NOT follow fixed bit-by-bit rules that digital circuits can implement directly.

  • Masking uses bitwise logic to keep, clear, or modify selected bits in a binary value.

  • Shift operations move bits left or right and are often tied to powers of 2.

  • In Intro to Electrical Engineering, you use bitwise operations to trace registers, logic outputs, and digital control signals.

Frequently asked questions about bitwise operations

What is bitwise operations in Intro to Electrical Engineering?

Bitwise operations are logic operations that work on each binary digit separately. In Intro to Electrical Engineering, they show up when you analyze digital circuits, masks, shifts, and binary register values. They are the bridge between binary math and hardware behavior.

How is XOR different from OR?

OR gives 1 when at least one input bit is 1, so two 1s still produce 1. XOR gives 1 only when the bits are different, so 1 and 1 become 0. That difference is why XOR is useful for toggling bits instead of just setting them.

How do you use bitwise operations to mask bits?

You line up a binary mask with the value you want to change. AND is the usual choice for clearing unwanted bits, OR is used for setting bits, and XOR can flip bits when you want to toggle a specific pattern. The mask controls which positions are affected.

Do bitwise shifts mean the same thing as multiplying and dividing?

Often, yes, but only in the right binary context. A left shift usually multiplies an unsigned binary number by 2 for each shift, and a right shift usually divides by 2. The catch is that the exact result can depend on whether the value is signed or unsigned.