Binary Operations Calculator

Convert between binary, decimal, and hex formats or perform bitwise operations

Convert between binary, decimal, and hexadecimal number systems and perform binary arithmetic operations with step-by-step explanations.

Updated June 2026 · How this works

Example calculation — edit any field to use your own numbers

Worth knowing
How It Works
The formula, explained simply

Think of binary like a light switch bank where each position can only be on or off. Just as you might use multiple light switches to create different lighting combinations, binary uses multiple digit positions to represent any number. Each position from right to left represents a power of 2: 1, 2, 4, 8, 16, and so on.

When you see 101010 in binary, you're looking at positions that represent 32 + 8 + 2 = 42 in decimal. The zeros mean those power-of-2 positions are "off" while the ones mean they're "on." This system mirrors exactly how computer processors store and manipulate numbers internally.

Hexadecimal serves as a shorthand for binary, with each hex digit representing exactly four binary digits. The digit A in hex equals 1010 in binary, making it much easier to read long binary numbers. This is why memory addresses and color codes use hexadecimal notation.

When To Use This
Right tool, right situation

Use binary operations when working with individual bits, such as setting permission flags, creating bit masks, or optimizing memory usage. Game programmers often use bitwise operations to pack multiple boolean values into single integers, saving memory and improving performance.

Number base conversion becomes essential when reading technical documentation, debugging assembly code, or working with hardware interfaces. Network administrators regularly convert between decimal IP addresses and their binary representations to understand subnet masks and routing.

Avoid using this calculator for floating-point numbers or when you need precise decimal arithmetic. Binary representation of decimal fractions often results in approximations, which can accumulate errors in financial calculations or scientific computations requiring exact precision.

Common Mistakes
Why results sometimes look wrong

The most common mistake is confusing bitwise operations with logical operations. Bitwise AND (&) compares individual bits, while logical AND (&&) treats entire numbers as true or false values. Using the wrong operator can produce completely different results in programming.

Many people assume negative numbers work the same in binary as in decimal, but computers use two's complement representation. This means -1 appears as all 1s in binary, not just 1 with a minus sign. This representation affects how arithmetic and bitwise operations behave with negative numbers.

Another frequent error is forgetting that integer division in binary systems truncates toward zero, not rounds to the nearest value. When 7 divided by 2 equals 3 instead of 3.5, programmers sometimes get unexpected results in calculations that depend on precise division.

The Math
Worked examples and deeper derivation

Binary arithmetic follows the same rules as decimal arithmetic, but carries happen at 2 instead of 10. When adding 1 + 1 in binary, you get 10 (not 2), just like 9 + 1 becomes 10 in decimal. This carry behavior extends to all operations.

Bitwise operations work differently than arithmetic operations. Bitwise AND compares each bit position independently - if both positions contain 1, the result is 1, otherwise 0. This makes it perfect for testing whether specific bits are set or for masking out unwanted bits.

Shift operations multiply or divide by powers of 2. Left shifting by one position doubles the number, while right shifting halves it (with truncation). This makes binary shifts much faster than multiplication or division in computer processors, which is why programmers optimize code using bit shifts.

Converting RGB color values to hexadecimal
Red value 255 in decimal, converting to hexadecimal format
Result shows FF in hexadecimal, which web developers use in CSS color codes. The binary 11111111 shows all 8 bits set to maximum value.
Calculating network subnet masks
Binary 11111111111111111111111100000000 representing a /24 subnet mask
Result shows 4,294,967,040 in decimal and FFFFFF00 in hex. Network administrators use these formats to configure routers and firewalls.
Programming bit manipulation
Decimal 12 AND 10 for checking common set bits
Result shows 8, meaning only bit position 3 is set in both numbers. Programmers use bitwise operations for flags, permissions, and optimization.
Expert Unlock
The thing most explanations skip

Professional developers recognize that bitwise operations execute in constant time regardless of the numbers involved, making them ideal for performance-critical code. Bit manipulation tricks like using XOR to swap variables without temporary storage, or using bit masks to implement state machines, separate junior from senior programmers. The calculator's 32-bit limitation reflects most programming environments, where integer overflow behavior must be understood to prevent security vulnerabilities in production systems.

How do I read binary numbers?

What's the difference between bitwise AND and regular addition?
Bitwise AND compares each bit position and returns 1 only when both bits are 1. Regular addition carries values between positions like normal arithmetic. AND is used for masking specific bits in programming.
Why do programmers use hexadecimal instead of binary?
Hexadecimal is more compact than binary while staying close to how computers work. Each hex digit represents exactly 4 binary digits, making it easier to read memory addresses and color codes.
What happens when binary numbers get too large?
Most programming systems use fixed-size integers like 32-bit or 64-bit. When results exceed these limits, the extra bits are truncated or the number wraps around to negative values using two's complement representation.

Need something this doesn't cover?

Suggest a tool — we'll build it →