Bitwise operators in C: AND (&), OR (|), XOR (^), left shift (<<), right shift (>>), and one's complement (~) explained with examples

Bitwise Operator Example

a b a&b a|b a<<b a>>b
5 3 1 7 40 0

🎯 Why Bitwise Operators are Important for Learners Worldwide

  • ⚡ Performance: Bitwise operations are up to 10x faster than arithmetic operations — the same in any programming language, anywhere in the world
  • 💻 Hardware Programming: Essential for embedded systems, device drivers, and microcontroller programming on every continent
  • 💼 Career: Essential for FAANG, embedded systems, game dev, and cybersecurity roles globally
  • 🎮 Gaming: Used in every game engine — from Unity to Unreal, from US to Asia
  • 🔒 Security: Used in encryption algorithms, hashing, and checksum calculations worldwide

📚 Trusted References & Recommended Resources

🤔 People Also Ask

Q: What is the difference between & and && in C?
A: & is bitwise AND (works on individual bits), while && is logical AND (works on boolean values). This applies to every C compiler.

Q: Can bitwise operators be used on floats in C?
A: No, bitwise operators only work on integer types (int, char, short, long). This is true for all C standards worldwide.

Q: What is the fastest way to multiply by 2 in C?
A: Use left shift: n << 1 is faster than n * 2 on any CPU architecture.

Q: How do I check if a number is a power of 2 using bitwise operators?

Use n & (n-1). If the result is 0, the number is a power of 2. This is a favorite interview question globally!

🔒 Trust & Transparency

  • Verified Organization: Sankalan Data Tech Team — 15+ years of experience, training students across countries
  • HTTPS Secure: Your connection to this page is encrypted
  • No Affiliate Links: This tutorial contains no sponsored content

Other Tutorials
SQL FAQJava FAQPython FAQ

Previous Topic:-->>Logical Operators || Next topic:-->>?, *, &, sizeof() Operators

⬆ Top & | ^ << >> ~