Programmer calculators

Add and multiply in binary and hex, store negative numbers in a fixed number of bits, read floats, and simplify logic. Each calculator shows its working.

Carries shown in red

In decimal that is 11 + 6 = 17

Runs in your browser. Nothing you type is uploaded.

Arithmetic in binary and hex

For sums where a column carries at 2 or at 16.

Binary calculatorAdd, subtract, multiply, divide, AND, OR, XOR1011 + 0110 → 10001
Hex calculatorHex math with the working shown2B9 + FA7 → 1260
XOR calculatorXOR, AND, OR and more on any values1100 XOR 1010 → 0110

Signed numbers and floats

For values stored in a fixed number of bits.

Two's complementSigned binary in 4 to 64 bits-5 in 8 bits → 11111011
IEEE 754 converterDecimal to float bits and back0.1 → 0x3DCCCCCD
One's complementFlip bits, signed values and checksums-5 in 8 bits → 11111010

Logic and Boolean algebra

For expressions, truth tables and circuits.

Karnaugh map solverSimplify logic with a K-mapm(0, 2, 8, 10) → B'D'
Boolean algebra calculatorSimplify Boolean expressionsA'B + AB → B
Truth table generatorBuild a truth tablep → q → false only when p is true and q is false

How big a number fits in 8, 16, 32 or 64 bits

Signed types give up one bit for the sign, so their top value is about half the unsigned one.

BitsUnsigned rangeSigned rangeSigned max in hex
80 to 255-128 to 1277F
160 to 65,535-32,768 to 32,7677FFF
320 to 4,294,967,295-2,147,483,648 to 2,147,483,6477FFFFFFF
640 to 18,446,744,073,709,551,615-9,223,372,036,854,775,808 to 9,223,372,036,854,775,8077FFFFFFFFFFFFFFF

What happens when you go one past the top

The bits roll over and the sign bit flips, so a signed number jumps from its maximum to its minimum.

TypeSumIn binary or hexResult
8-bit signed127 + 101111111 + 1 = 10000000-128
8-bit unsigned255 + 1FF + 1 = 100, top bit dropped0
32-bit signed2,147,483,647 + 17FFFFFFF + 1 = 80000000-2,147,483,648

What an ordinary calculator gets wrong

A phone calculator works in base 10 and keeps numbers as long as it likes. Code does neither. A column carries at 2 or 16, a negative number has to fit in 8, 16 or 32 bits, and a decimal like 0.1 cannot be stored exactly, so 0.1 + 0.2 comes out a little over 0.3.

These calculators work the way a processor does and show every step: each carry, each borrow, each flipped bit. That makes them useful for checking a hand calculation as well as for getting the answer.

Frequently asked questions

What is 2147483647?

It is the largest value a signed 32-bit integer can hold, 231 − 1, written 7FFFFFFF in hex. Many languages call it INT_MAX or Int32.MaxValue. Add 1 and a 32-bit signed value wraps to -2,147,483,648.

What is the difference between signed and unsigned integers?

An unsigned integer uses every bit for the size of the number, so 8 bits hold 0 to 255. A signed integer uses two's complement, where the top bit counts as negative, so 8 bits hold -128 to 127. Both store 256 different values; they cover a different stretch of the number line.

What is integer overflow?

Overflow happens when a result needs more bits than the type has. The extra bit is dropped and the value wraps around, so 255 + 1 in an unsigned byte gives 0. In C, overflow of a signed integer is undefined behavior, which means the compiler is free to assume it never happens.

Scroll to Top