Skip to content

Programmer Calculator

Inspect ECMAScript 32-bit AND, OR, XOR, NOT, and shift results simultaneously as signed, unsigned, hexadecimal, and binary values.

Privacy: your files never leave your device. All processing happens locally in your browser.

How to use

  1. 1.Choose the radix shared by the entered operands.
  2. 2.Enter operand A and operand B or a 0–31 shift count, then choose the operation.
  3. 3.Calculate and inspect signed, unsigned, hex, and binary views before copying the 32-bit result.

About Programmer Calculator

Programmer Calculator performs common 32-bit bitwise operations and displays the same result as signed decimal, unsigned decimal, eight-digit hexadecimal, and 32-bit binary. Choose an input base, enter operands, select AND, OR, XOR, NOT, left shift, signed right shift, or unsigned right shift, and calculate locally. The formatted result can be copied.

This tool follows ECMAScript Number bitwise semantics. Operands are converted to 32-bit integers represented in two’s complement before an operation. AND sets a bit only when both input bits are one. OR sets it when either is one. XOR sets it when exactly one is one. NOT flips every one of the 32 bits. The ECMAScript specification and MDN tables independently define these rules.

Left shift moves bits left and inserts zeros on the right, discarding high bits. Signed right shift copies the sign bit into new high positions. Unsigned right shift inserts zeros and therefore returns an unsigned value from 0 through 4294967295. Shift counts are deliberately limited to 0–31, matching the effective 32-bit word positions without hiding JavaScript’s modulo-32 behavior.

Inputs may be written in base 2, 8, 10, or 16 without prefixes. For example, FF in base 16 is 255 and -101 in base 2 is -5. Parsing is strict: a digit outside the selected radix is rejected, so decimal 2 cannot silently pass as binary. Input is bounded to the signed lower limit and unsigned upper limit of one 32-bit word.

The signed and unsigned lines are two interpretations of identical bits. Hexadecimal and binary use the unsigned pattern, padded to eight hex digits and 32 bits. Thus NOT 5 has signed value -6, unsigned value 4294967290, hex FFFFFFFA, and a binary pattern beginning with ones. Overflow wraps because bits beyond the 32-bit word are discarded; 2147483647 shifted left once becomes signed -2.

This page intentionally differs from a general number-base converter. Conversion is included only to inspect operands and operation results. It does not evaluate arbitrary expressions, precedence, floating point, 64-bit machine integers, CPU flags, rotations, masks wider than 32 bits, or language-specific behavior outside ECMAScript Number bitwise operators. BigInt semantics are also different and are not used here.

Eight specification-derived goldens cover every operation family, signed and zero-fill right shift, NOT, and overflow. Additional tests cover strict hexadecimal and binary parsing plus invalid digits. The output preserves all 32 bits, preventing the common mistake of showing a negative result without its actual two’s-complement pattern.

Use the calculator to learn masks, debug flags, check protocol fields, or compare JavaScript bitwise results. Confirm the required word width, signedness, endianness, shift rules, and target language before applying an answer to embedded systems, binary file formats, cryptography, or network protocols.

The calculator does not show byte order because a numeric word has no serialization order until written as bytes. For a file or packet, separately confirm big-endian or little-endian layout; the padded bit pattern cannot answer that representation question.

Methodology & sources

Strictly parse integers in radix 2, 8, 10, or 16 within one 32-bit word, apply ECMAScript Number AND/OR/XOR/NOT/SHL/SHR/USHR rules, limit shifts to 0–31, and render the identical result bits as signed, unsigned, padded hex, and padded binary.

Frequently asked questions

Why can a positive input produce a negative result?
The same 32-bit pattern is negative when its high bit is interpreted as a signed two’s-complement sign bit.
What is the difference between SHR and USHR?
SHR propagates the sign bit; USHR fills high bits with zero and returns an unsigned value.
Can I calculate 64-bit values?
No. This page deliberately follows ECMAScript Number 32-bit bitwise semantics.
Should I include 0x or 0b prefixes?
No. Choose the input base and enter digits without a prefix.

Calculators guides

View all