UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

Free eBooks·About·Changelog·Privacy Policy·Terms of Service·Report a bug
HomeCompetitive ProgrammingBitwise Visualizer

Related Tools

Code FormatterMatrix GeneratorComplexity CalcBit VisualizerBit ManipulationBitmask PlannerPrime FactorsMEX CalcInterval MergerMatrix RotationPBDS GeneratorSegment TreeGraph VisualizerStress TesterModulo CalcConvex HullPath FinderOffline JudgeBig-O AnalyzerCombinatoricsDP Table BuilderExtended GCDSieve VisualizerBinary SearchSorting VisualizerSparse Table RMQUnion-Find DSU

Bitwise Operations Visualizer

Flip bits in two operands and watch AND, OR, XOR, NOT and all three shift operators resolve column by column at 8, 16 or 32-bit width.

You Might Also Like

All Competitive Programming

Bit Visualizer

Toggle 32/64-bit grids. Click bits to flip them live and see decimal recalculate. Shows popcountll, clzll, ctzll, and MSB instantly.

Code Formatter

Format and beautify C++, Java, and Python code with consistent indentation. 100% client-side — no code leaves your browser.

Matrix Generator

Generate grid/matrix inputs for competitive programming. Random, zeros, identity, or sequential fill. Outputs in multiple formats.

Complexity Calc

Estimate Big-O operations and runtime for any N. Interactive reference table for all complexity classes from O(1) to O(N!).

Two numbers go in. What happens between them, column by column, is the part textbooks draw badly and a static diagram cannot show at all. Operand A gets a row of clickable cells, operand B gets its own, and the result sits under both. Click any cell and the operand field rewrites itself, every readout recalculates, and the bit-by-bit trace updates to match.

Both fields read three notations independently: plain decimal, 0x hex, and 0b binary. That means 0xBEEF in one field and 13 in the other is a perfectly legal pair. A leading minus works everywhere too. Type -1 at 32-bit width and you get 4294967295 with all thirty-two cells lit, which is the quickest demonstration of two's complement anyone has come up with.

Width is a toggle, not a commitment. Drop 48879 from 32-bit down to 8-bit and the field keeps exactly what you typed while the register wraps to 239, with a line underneath saying so. Keeping the literal and the register visibly separate is the whole point when you are checking whether a value survives a narrowing cast.

Walkthrough: 0xBEEF Against 13

The first press of Load Sample Data fills operand A with 0xBEEF and operand B with 13 — one hex literal and one decimal, because the parser takes both and the sample ought to prove it. 0xBEEF is 48879, or 1011 1110 1110 1111 in binary, and it happens to carry 13 set bits of its own. Run all seven operators against that pair at 32-bit width:

  • A & B = 13, because the low nibble of A is 1111 and 13 is 1101
  • A | B = 48879, unchanged, for the same reason: every bit of B is already set in A
  • A ^ B = 48866 — only bit 1 differs, so only bit 1 flips
  • ~A = 4294918416 unsigned, −48880 signed, 0xFFFF4110 in hex
  • A << 13 = 400416768, which is 0x17DDE000
  • A >> 13 and A >>> 13 both = 5

That last pair agrees only because A is positive. Click cell 31 in row A to set the sign bit and the two answers separate at once: the arithmetic shift starts copying ones into the vacated high bits while the logical shift keeps feeding zeros. Watching them diverge on the same input is worth more than reading the rule twice.

How the Math Avoids JavaScript's 32-Bit Trap

Open a browser console and evaluate 1 << 32. You get 1, not 0, because JavaScript masks every shift count down to five bits. Evaluate 0xFF00FF00 | 0 and you get −16711936, because the operands were coerced to signed 32-bit first. Those two results are precisely the confusion this page exists to remove, so none of the shifting here goes through << or >>.

Each value is wrapped into the active width, shifted by multiplying or dividing by a power of two, then wrapped again. The boolean operators still run natively, since their bit pattern is correct for any 32-bit input, but each result passes through >>> 0 so the pattern reads back unsigned. The arithmetic right shift builds its sign fill with addition rather than a bitwise OR, which is exact because the shifted value and the fill never occupy the same column.

What Happens When the Shift Count Runs Past the Width

Operand B doubles as the shift distance, so it can overrun the register without much effort. Press Load Sample twice and B arrives as 0x0F0F0F0F, a distance of 252645135 places.

  • Counts at or above the width return zero, and a note says which: “Shift count 252645135 is at or above the 32-bit width — every bit leaves the register.” C calls this undefined behaviour and JavaScript quietly computes B % 32; neither answer is honest, so this reports the limit instead.
  • One exception: an arithmetic right shift of a negative value past the width returns all ones, 0xFFFFFFFF, not zero. The sign bit has nowhere left to propagate from, so it fills the register.
  • Garbage input counts as zero rather than freezing the grid. Anything unparseable draws “Enter a decimal, 0x hex, or 0b binary value.” under the field while the rest of the page keeps working.
  • Underscores and apostrophes are stripped before parsing, so 0b1011_0011 and 1'000'000 paste in from Rust or C++ source without hand-editing.
  • NOT ignores operand B entirely. Select it and row B dims rather than disappearing, so the layout does not jump while you compare operators.

The detail most people miss: flipping a cell rewrites the field in whatever notation it already held. Click bit 2 while operand A reads 0xBEEF and the field becomes 0x0000BEEB, zero-padded to the register width, not 48875. Hex stays hex, binary stays binary, and a decimal field stays decimal.

read as hex → 48879 = 0x0000BEEF

read as decimal → 13 = 0x0000000D

Operation

Click any cell in A or B to flip that bit — the operand field rewrites itself in the same notation and every readout follows. Bit 0 is the rightmost column.

A0000 0000 0000 0000 1011 1110 1110 1111
B0000 0000 0000 0000 0000 0000 0000 1101
A & B0000 0000 0000 0000 0000 0000 0000 1101
310
300
290
280
270
260
250
240
230
220
210
200
190
180
170
160
150
140
130
120
110
100
90
80
70
60
50
40
31
21
10
01

Operand A

unsigned
48879
signed
48879
hex
0x0000BEEF
octal
0o00000137357

Operand B

unsigned
13
signed
13
hex
0x0000000D
octal
0o00000000015

A & B

unsigned
13
signed
13
hex
0x0000000D
octal
0o00000000015

Result binary

0000 0000 0000 0000 0000 0000 0000 1101

Bit-by-bit trace

A result bit is 1 only where both input bits are 1.

Hover or tab any cell in the grids above to pin its column here.
  • Bit 31 of A is 0, bit 31 of B is 0 → 0 & 0 = 0
  • Bit 30 of A is 0, bit 30 of B is 0 → 0 & 0 = 0
  • Bit 29 of A is 0, bit 29 of B is 0 → 0 & 0 = 0
  • Bit 28 of A is 0, bit 28 of B is 0 → 0 & 0 = 0
  • Bit 27 of A is 0, bit 27 of B is 0 → 0 & 0 = 0
  • Bit 26 of A is 0, bit 26 of B is 0 → 0 & 0 = 0
  • Bit 25 of A is 0, bit 25 of B is 0 → 0 & 0 = 0
  • Bit 24 of A is 0, bit 24 of B is 0 → 0 & 0 = 0
  • Bit 23 of A is 0, bit 23 of B is 0 → 0 & 0 = 0
  • Bit 22 of A is 0, bit 22 of B is 0 → 0 & 0 = 0
  • Bit 21 of A is 0, bit 21 of B is 0 → 0 & 0 = 0
  • Bit 20 of A is 0, bit 20 of B is 0 → 0 & 0 = 0
  • Bit 19 of A is 0, bit 19 of B is 0 → 0 & 0 = 0
  • Bit 18 of A is 0, bit 18 of B is 0 → 0 & 0 = 0
  • Bit 17 of A is 0, bit 17 of B is 0 → 0 & 0 = 0
  • Bit 16 of A is 0, bit 16 of B is 0 → 0 & 0 = 0
  • Bit 15 of A is 1, bit 15 of B is 0 → 1 & 0 = 0
  • Bit 14 of A is 0, bit 14 of B is 0 → 0 & 0 = 0
  • Bit 13 of A is 1, bit 13 of B is 0 → 1 & 0 = 0
  • Bit 12 of A is 1, bit 12 of B is 0 → 1 & 0 = 0
  • Bit 11 of A is 1, bit 11 of B is 0 → 1 & 0 = 0
  • Bit 10 of A is 1, bit 10 of B is 0 → 1 & 0 = 0
  • Bit 9 of A is 1, bit 9 of B is 0 → 1 & 0 = 0
  • Bit 8 of A is 0, bit 8 of B is 0 → 0 & 0 = 0
  • Bit 7 of A is 1, bit 7 of B is 0 → 1 & 0 = 0
  • Bit 6 of A is 1, bit 6 of B is 0 → 1 & 0 = 0
  • Bit 5 of A is 1, bit 5 of B is 0 → 1 & 0 = 0
  • Bit 4 of A is 0, bit 4 of B is 0 → 0 & 0 = 0
  • Bit 3 of A is 1, bit 3 of B is 1 → 1 & 1 = 1
  • Bit 2 of A is 1, bit 2 of B is 1 → 1 & 1 = 1
  • Bit 1 of A is 1, bit 1 of B is 0 → 1 & 0 = 0
  • Bit 0 of A is 1, bit 0 of B is 1 → 1 & 1 = 1