Bitwise Calculator
Perform bitwise operations with visual binary representation and step-by-step breakdowns.
About This Tool
The Bitwise Calculator is a free browser-based tool that lets developers perform bitwise operations on integers with a visual, interactive interface. Whether you are working with low-level networking code, embedded systems firmware, graphics programming, or permission flags, this tool helps you understand and verify bitwise manipulations instantly.
Supported operations include AND (&), OR (|), XOR (^), NOT (~), Left Shift (<<), Right Shift (>>), and Unsigned Right Shift (>>>). Each operation displays the result in all four common number formats — decimal, hexadecimal, octal, and binary — so you can quickly copy whichever representation you need.
The visual 32-bit grid shows each bit as 0 or 1 with color coding. You can click individual bits to toggle them, making it easy to construct specific bitmask values without manual calculation. The step-by-step breakdown section shows exactly how the operation works bit by bit, which is invaluable when debugging complex bitwise expressions.
If you work with different data sizes, you can switch between 8-bit, 16-bit, and 32-bit widths. The tool automatically masks values to the selected width and correctly handles signed vs. unsigned representations. The dedicated bitmask operations section provides one-click set bit, clear bit, toggle bit, and check bit functions — common patterns in flag-based programming.
All processing happens entirely in your browser. Your data never leaves your machine — there are no server requests, no logging, and no third-party tracking. If you need to convert between number bases, try the Number Base Converter. For working with raw hex data, check out the Hex Editor.
How to Use
- Enter a number in the Input A field. The tool auto-detects decimal, hexadecimal (prefix with 0x), or binary (prefix with 0b) format.
- Select a bit width (8-bit, 16-bit, or 32-bit) using the buttons at the top.
- Choose a bitwise operation (AND, OR, XOR, NOT, <<, >>, >>>) from the operation selector.
- For binary operations, enter a second number in Input B. For NOT, only Input A is used.
- View the result in all formats (decimal, hex, octal, binary) and the visual bit grid below.
- Click any individual bit in the bit grids to toggle it and see how the result changes.
- Use the Common Bitmask Operations section to quickly set, clear, toggle, or check a specific bit position.
- Press Ctrl+Shift+C to copy the decimal result to your clipboard.
Popular Bitwise Operation Examples
FAQ
Is my data safe when using this tool?
Yes. All bitwise calculations are performed entirely in your browser using JavaScript. No data is sent to any server. You can safely use this tool with any values without privacy concerns.
What number formats can I enter?
You can enter numbers in decimal (e.g., 42), hexadecimal with 0x prefix (e.g., 0x2A), or binary with 0b prefix (e.g., 0b101010). The tool auto-detects the format and displays a badge showing which format was detected.
What is the difference between >> and >>>?
The >> operator (arithmetic right shift) preserves the sign bit, so negative numbers stay negative after shifting. The >>> operator (unsigned right shift) fills the leftmost bits with zeros, always producing a non-negative result. This distinction matters for signed integers.
How does the bit width setting affect calculations?
The bit width (8, 16, or 32) determines how many bits are used for the calculation. Values are masked to fit the selected width. For example, in 8-bit mode, 256 becomes 0 because only the lower 8 bits are kept. This simulates how integers behave in fixed-width registers.
What are common uses for bitwise operations?
Bitwise operations are used for permission flags (Unix file permissions), network subnet masking, embedded systems register manipulation, graphics color channel extraction, cryptographic algorithms, data compression, and performance-optimized arithmetic (multiplying/dividing by powers of 2 using shifts).
Can I toggle individual bits by clicking?
Yes. Click any bit in the visual bit grid for Input A or Input B to flip it between 0 and 1. The input value and all results update automatically. This is useful for constructing specific bitmask values.
How do the bitmask operations work?
Set bit uses value | (1 << pos) to set a specific bit to 1. Clear bit uses value & ~(1 << pos) to set a bit to 0. Toggle bit uses value ^ (1 << pos) to flip a bit. Check bit uses (value & (1 << pos)) !== 0 to test whether a bit is set.
Related Tools
Number Base Converter
Convert numbers between binary, octal, decimal, hexadecimal, and custom bases with bit visualization.
Hex Editor
View and edit files or text as hexadecimal. Hex dump with offset, hex, and ASCII columns.
Text to Binary Converter
Convert text to binary, octal, decimal, and hex representations. Visualize individual bits with 8-bit grouping.
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes for text and files.
Matrix Calculator
Perform matrix addition, multiplication, transpose, determinant, inverse, row echelon form, and rank calculations with step-by-step solutions.
IEEE 754 Inspector
Inspect IEEE 754 single and double precision floating-point numbers with interactive bit visualization and comparison mode.