Skip to content

Programmer Calculator

Evaluate arithmetic and bitwise expressions (AND, OR, XOR, NOT, shifts, modulo) and see the result in decimal, hexadecimal, binary and octal.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is Programmer Calculator?

This programmer calculator evaluates the kind of expressions developers write in code and shows the result in every common number base. Type an expression such as 255 & 15, 1 << 8 or 300 ^ 255 and you instantly see the answer in decimal, hexadecimal, binary and octal.

Operator buttons insert AND (&), OR (|), XOR (^), NOT (~), shift left (<<), shift right (>>) and modulo (%), alongside the usual + − × ÷ and parentheses. It is ideal for working with bit flags, masks, permissions, colors and protocol fields without switching to your OS calculator's programmer mode.

How to use Programmer Calculator

  1. Type an expression in decimal, such as 255 & 15 or (12 |
  2. <<
  3. Or use the operator buttons to insert &, |, ^, ~, <<, >> and %.
  4. Read the result in decimal, hexadecimal (0x…), binary (0b…) and octal (0o…).
  5. Copy the representation you need.

Key features

  • Arithmetic and bitwise expressions: & | ^ ~ << >> % plus + − × ÷ and parentheses
  • Result shown in decimal, hexadecimal, binary and octal at once
  • Operator buttons for quick input
  • Binary output grouped into 4-bit nibbles
  • Copy buttons for each number base

Common use cases

  • Combining and testing bit flags and masks
  • Working out Unix permission bits and feature-flag values
  • Converting results between hex, binary and decimal while debugging
  • Checking bit-shift arithmetic in embedded and network code
  • Learning how bitwise operators behave

Technical details & standards

Expressions follow JavaScript operator rules: bitwise operators work on 32-bit signed integers, so ~0 is −1 and 1 << 31 is −2147483648, and operator precedence matches JavaScript (shifts bind tighter than &, which binds tighter than ^ and |). Use parentheses to make the order explicit. The result is shown as an integer, rounded down; binary is padded to at least 16 bits and grouped in nibbles for readability.

Numbers are entered in decimal. Common identities: x & (x − 1) clears the lowest set bit, x | (1 << n) sets bit n, x & ~(1 << n) clears it, and x ^ y flips the bits where x and y differ.

Frequently asked questions

What does the XOR (^) operator do?

XOR compares two numbers bit by bit and sets a bit to 1 where exactly one of them has a 1. For example 12 ^ 10 is 1100 ^ 1010 = 0110, which is 6. XORing a value with the same mask twice restores the original.

What is the difference between >> and >>>?

In JavaScript, >> is an arithmetic right shift that keeps the sign, so negative numbers stay negative. >>> is a logical right shift that fills with zeros and always gives a non-negative result. This calculator provides the >> operator.

Why does ~5 give -6?

Bitwise NOT flips all 32 bits of the number. In two's complement, flipping every bit of x gives −x − 1, so ~5 = −6 and ~0 = −1.

How do I check whether a specific bit is set?

AND the value with a mask for that bit: (value & (1 << n)) != 0 is true when bit n is set. For example 13 & (1 << 2) is 4, so bit 2 of 13 (binary 1101) is set.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More calculators tools

View all