🔢 Bitwise Operation Tool – Visual Binary Calculator
The Bitwise Operation Tool is an interactive utility that performs bitwise operations on integer values in real time. It is designed for developers, students, and engineers who work with binary arithmetic, embedded systems, networking protocols, cryptography, and low-level data manipulation. Enter operands in any number base, select an operation, and immediately see a color-coded bit grid, multi-base output, and a per-bit step-by-step explanation.
⚙️ Supported Operations
| Operation | Symbol | Description | Common Use |
|---|---|---|---|
| AND | & | Result bit is 1 only when both inputs are 1 | Masking / clearing bits |
| OR | | | Result bit is 1 when at least one input is 1 | Setting specific bits |
| XOR | ^ | Result bit is 1 when inputs differ | Toggle, parity, encryption |
| NOT | ~ | Flips every bit within the register width | Bitwise complement |
| Left Shift | << | Shifts bits left; vacated positions filled with 0 | Multiply by 2ⁿ |
| Right Shift (Logical) | >>> | Shifts bits right; fills high bits with 0 | Unsigned divide by 2ⁿ |
| Right Shift (Arithmetic) | >> | Shifts bits right; preserves sign bit | Signed divide by 2ⁿ |
| Rotate Left | ⟲ | Bits wrap from MSB to LSB end | Hashing, ciphers |
| Rotate Right | ⟳ | Bits wrap from LSB to MSB end | Hashing, ciphers |
| Set Bit | S | Forces a specific bit to 1 | Bit flag manipulation |
| Clear Bit | C | Forces a specific bit to 0 | Bit flag manipulation |
| Toggle Bit | T | Flips a specific bit | State toggling |
| Test Bit | ? | Reads value of a specific bit without modifying | Flag checking |
🖥️ Interactive Bit Grid
The tool renders a color-coded bit grid for Operand A, Operand B, and the Result. Each cell represents one bit position:
- Green cells — Operand A set bits (value = 1)
- Orange cells — Operand B set bits (value = 1)
- Blue cells — Result set bits (value = 1)
- Gray cells represent clear bits (value = 0)
Click any cell in the Operand A or B grid to toggle that bit on or off. The result updates instantly, making it easy to explore how individual bit changes affect the outcome — ideal for understanding masking, setting, and clearing patterns.
📐 Multi-Base Input and Output
Operands can be entered in decimal, hexadecimal, octal, or binary notation. The result is always displayed simultaneously in all four bases, each with a one-click copy button. This eliminates the need to manually convert between bases while debugging register values, network packets, or memory addresses.
Example — AND operation (8-bit):
Operand A = 0b10110101 (181 dec / 0xB5 hex)
Operand B = 0b11001111 (207 dec / 0xCF hex)
─────────────────────────────────────────────
Result = 0b10000101 (133 dec / 0x85 hex)🔄 Shift and Rotate Operations
Shift and rotate operations require a shift amount from 0 to (bit width − 1). For logical right shift (>>>), vacated high-order bits are filled with 0, preserving unsigned semantics. For arithmetic right shift (>>), the sign bit is propagated, which correctly handles negative values in two's-complement representation.
Rotate operations (⟲ / ⟳) perform a circular shift — bits that overflow one end re-enter from the other, so no bit information is lost. This is the core mechanism in many cryptographic hash functions such as SHA-256 and SHA-512.
🧮 Result Metrics
Each calculation also reports several derived metrics useful in low-level programming and digital logic design:
- Population Count (Hamming Weight) — the number of set bits (1s) in the result, visualized as a progress bar from sparse (green) to dense (red).
- Parity — even if the count of set bits is even, odd otherwise. Used for error detection in communication protocols.
- MSB / LSB — the most and least significant bits of the result.
- Carry Out — signals that a bit shifted off the end during shift operations.
🎯 Real-World Use Cases
- Network subnetting — apply AND between an IP address and a subnet mask to extract the network address. Use the built-in subnet mask presets (e.g.,
255.255.255.0) to load common masks instantly. - Embedded systems — set, clear, or toggle individual GPIO register bits without affecting adjacent bits using OR, AND/NOT, and XOR patterns.
- Cryptography education — visualize XOR-based one-time pads, understand how SHA-256 uses rotate operations in its compression function, or explore how cipher algorithms manipulate individual bits.
- Compiler and OS internals — quickly verify bitmask constants for page flags, permission bits, file-system flags, or hardware status registers.
- Computer science coursework — step through AND/OR/XOR truth tables bit-by-bit using the step-by-step explanation panel.
🔧 Register Width and Signed Mode
The tool supports 8-bit, 16-bit, 32-bit, and 64-bit register widths. For 64-bit operations, JavaScript's BigInt type is used internally to avoid the 32-bit signed ceiling of native JS bitwise operators, ensuring accurate results across all widths.
Enabling Signed (Two's Complement) mode interprets the most significant bit as a sign bit. In this mode, the decimal output shows negative values for numbers whose MSB is 1 — for example, 0b11111110 in signed 8-bit mode equals -2 in decimal rather than 254.