Math / Computer Science

Programmer Calculator

Convert between decimal, binary, octal, and hexadecimal, and run bitwise operations at 8, 16, 32, or 64-bit word sizes.

Base conversionBitwise AND/OR/XORTwo's complement8–64 bit

Word size

Enter signed decimal values. Negative numbers are shown in two's-complement notation at the selected width, with both signed and unsigned interpretations.

Inputs

Operation

Results

Value A

DEC42
HEX2A
OCT052
BIN00101010
UNSIGNED42

Value B

DEC7
HEX07
OCT007
BIN00000111
UNSIGNED7

Result

DEC2
HEX02
OCT002
BIN00000010
UNSIGNED2

Need a change for Programmer Calculator?

About this calculator

Method, formulas, and limits.

What this does

Converts an integer between decimal, binary, octal, and hexadecimal at a selected word size, and applies AND, OR, XOR, NOT, and shift operations with a two's-complement interpretation.

Who it is for

Programmers, embedded developers, students, and anyone debugging bit masks, flags, protocol fields, or binary layouts.

How it works

Input values are parsed as signed decimal integers, masked to the selected word width, and displayed in all four bases as the exact two's-complement representation.

Limitations

This is a reference tool, not a language emulator. It does not interpret language-specific overflow traps, signedness, or machine instructions, and decimal input is limited to 20 digits.

Key calculations

Two's complement
negative values are stored as (2^width − |value|), which makes signed and unsigned the same bit pattern.
Bitwise AND / OR / XOR
AND: 1 if both bits are 1; OR: 1 if either is 1; XOR: 1 if the bits differ.
Shift
SHL shifts bits left filling zeros; SHR shifts right, and for signed values the sign bit is preserved in the two's-complement view.

How to use it

  1. 1.Enter an integerType a signed decimal value (up to 20 digits). Negative values use two's-complement notation.
  2. 2.Pick a word sizeChoose 8, 16, 32, or 64 bits; the displayed binary string is padded to that width.
  3. 3.Choose an operationAND, OR, XOR, and shifts use two operands; NOT uses only the first.
  4. 4.Read the basesThe result is shown in decimal, hex, octal, and binary so you can paste any representation.

Enter a decimal value, pick a word size, and choose an operation such as NOT. The panel shows the exact binary, hex, and octal representation of that value. For a pure conversion, any single-operand operation shows all four bases of the input.

Two's complement is how computers store signed integers: negative values wrap around the word size, so −1 in 8 bits is 0xFF. The calculator shows both the signed and unsigned decimal interpretation of the same bits.

Because the bits are the same. For example, −1 in 8 bits is 11111111, which is 255 when read as unsigned. The calculator shows both readings explicitly.

Results are masked to the selected word width, so bits shifted or carried beyond the width are dropped. Shift amounts larger than the width are clamped.

No. Languages differ in signedness, overflow handling, and shift semantics. Use this as a reference for the standard bit patterns, then confirm behavior in your toolchain.

Related calculators

Quick jumps