Skip to content
Logo Any Help Me

Programmer Calculator: Hex, Dec, Oct, Bin Converter

0
HEX0
DEC0
OCT0
BIN0

Arithmetic in the Bases Computers Use

A programmer calculator differs from a scientific one in what it treats as fundamental. It works in binary, octal, decimal and hexadecimal at once, showing the same value in every base simultaneously, and it offers bitwise operations, AND, OR, XOR, NOT and shifts, that manipulate individual bits rather than the number as a whole.

That combination is what makes it useful for reading a permission mask, checking a colour value, or working out why a shift produced an unexpected result.

How to Use the Programmer Calculator

The word size setting is the one that changes results silently, so it is worth checking before anything else.

  1. Choose the word size, 8, 16, 32 or 64 bits. This decides where values wrap and how NOT behaves, and is the most common source of surprising results.
  2. Enter a value in whichever base is convenient. The other three update immediately, which is the fastest way to convert.
  3. Use the bitwise operators for masks and flags: AND to test or clear bits, OR to set them, XOR to toggle them.
  4. Use shifts to multiply or divide by powers of two. A left shift by one doubles the value; a right shift halves it, discarding the bit that falls off the end.
  5. Watch for overflow. A value that exceeds the word size wraps around rather than growing, which is exactly what happens in a fixed-width integer in real code.

Why Word Size Changes the Answer

NOT is the clearest demonstration. In 8-bit, NOT 0 is 255. In 16-bit it is 65,535, and in 32-bit it is 4,294,967,295. The operation is identical, invert every bit, but the number of bits differs, so the result does too. Any calculation involving NOT, or any value that crosses the top of the range, depends on this setting.

Shifts have the same sensitivity. Shifting left pushes bits off the top of the word and they are gone, so 0x80 shifted left by one is 0x100 in 16-bit but 0x00 in 8-bit. This is not a quirk of the calculator; it is precisely what happens to a fixed-width integer in C, Java or Rust, which is why matching the word size to the type you are debugging matters.

Bitwise Operations

What each operator does and the job it is usually reached for.

OperatorEffectTypical use
AND (&)1 only where both bits are 1Test a flag, clear bits with a mask
OR (|)1 where either bit is 1Set flags without disturbing others
XOR (^)1 where the bits differToggle bits, simple checksums
NOT (~)Inverts every bitBuild an inverse mask
<< (left shift)Multiplies by 2 per positionFast multiplication, build masks
>> (right shift)Divides by 2 per positionFast division, extract bit fields

AND with a mask is how you read part of a packed value: an RGB colour 0xFF8800 gives its green channel as (value >> 8) & 0xFF. That pattern, shift into position, then mask, is the most common idiom in bit manipulation.

Bases in Everyday Development

Hexadecimal dominates because each digit maps to exactly four bits, so a byte is always two hex digits and the boundary is visible at a glance. Binary shows individual bits but becomes unreadable past a byte or two. Octal survives mainly in Unix file permissions, where each digit conveniently encodes read, write and execute for one class of user.

That is why chmod 755 means what it does: 7 is 111 in binary, granting read, write and execute to the owner, while 5 is 101, granting read and execute to group and others. Seeing the octal and binary side by side in a calculator makes the mapping obvious in a way the decimal 493 never does.

Frequently Asked Questions

What is a programmer calculator for?
Working in binary, octal, decimal and hexadecimal at once, and applying bitwise operations to individual bits. It is used for masks, flags, colour values, permissions and debugging shifts.
Why does NOT give different answers?
Because it inverts every bit in the word, and the word size decides how many bits that is. NOT 0 is 255 in 8-bit and 65,535 in 16-bit.
What does AND with a mask do?
It keeps only the bits that are 1 in both values, which is how you test a flag or isolate part of a packed number. Combined with a shift it extracts a field.
How do shifts relate to multiplication?
A left shift by one position multiplies by two, and a right shift divides by two. Bits pushed past the end of the word are discarded, which is where unexpected results come from.
Why is hexadecimal used so much?
Because one hex digit is exactly four bits, so a byte is always two digits. That makes byte boundaries visible at a glance in a way decimal does not.
What does chmod 755 mean in binary?
7 is 111, granting read, write and execute to the owner; 5 is 101, granting read and execute to group and others. Octal survives in permissions because each digit maps to one user class.
Is my input stored?
No. Everything is calculated in your browser and nothing you enter is transmitted.

Explore more in Tools

View all →