DEV Community

Dev Nestio
Dev Nestio

Posted on

Bitwise Calculator: Visual 32-bit AND/OR/XOR/NOT/Shifts in Your Browser

I built a browser-based bitwise calculator that performs AND, OR, XOR, NOT, NAND, NOR, XNOR, arithmetic/logical shifts, and rotate operations on 32-bit integers — with a live clickable bit grid.

Try it

🔗 Bitwise Calculator — DevNestio

Features

  • 13 operations: AND, OR, XOR, NOT A/B, NAND, NOR, XNOR, SHL, SHR, SHRA, ROTL, ROTR
  • Visual 32-bit grid: Click any bit to toggle Operand A on the fly
  • Multi-base input: Auto-detect 0xFF, 0b1010, 0o17, or decimal
  • 4 output formats: Hex, decimal, binary (grouped), octal — all with copy buttons
  • No server, no upload — everything runs in-browser

The JavaScript integer trap

Bitwise ops in JS coerce values to signed 32-bit integers. To get unsigned results you need >>> 0:

case NOT_A: return (~a) >>> 0;   // without >>> 0, ~0 shows as -1
case XNOR:  return (~(a ^ b)) >>> 0;
case ROTL:  return ((a << s) | (a >>> (32 - s))) >>> 0;
Enter fullscreen mode Exit fullscreen mode

Rotate without a dedicated instruction

JavaScript has no ROL/ROR, so combine two shifts:

// Rotate left by s bits
((a << s) | (a >>> (32 - s))) >>> 0
Enter fullscreen mode Exit fullscreen mode

Tested with 99 assertions

All core logic — parsing, computing, edge cases like XNOR with ~0xFF = 0xFFFFFF00 — covered in a Node.js test file using assert.


Part of DevNestio — a growing collection of 115 free browser-only developer tools.

Top comments (0)