Conversion Calculators

Binary, Hex, Decimal and Octal Calculator

Binary, octal, decimal and hexadecimal are four ways of writing the same magnitude: each digit is the digit multiplied by the base raised to its position. Type a whole number in any base and this page prints all four at once, then adds or subtracts two integers in exact 64-bit arithmetic.

Calculator

Convert a number
Add or subtract

Whole numbers only, up to 18,446,744,073,709,551,615 (64 bits). A decimal point, an exponent, and a 0x or 0b prefix are not accepted; spaces between digits are. Leave both arithmetic numbers blank to skip the sum.

Formula

All four bases are positional: a digit's value is the digit multiplied by the base raised to its position, counting from the right and starting at zero. The decimal 255 is 2 × 10² + 5 × 10¹ + 5 × 10⁰, and the same magnitude is 11111111 in binary (2⁷ + 2⁶ + … + 2⁰), 377 in octal, and ff in hexadecimal. Converting re-expresses one sum in another base; the addition and subtraction panel is the ordinary integer arithmetic on the same magnitude, so the base never changes the answer.

About This Calculator

What It Does

This page reads one whole number and prints it in all four bases at once — decimal (base 10), binary (base 2), octal (base 8) and hexadecimal (base 16) — and adds or subtracts two whole numbers, each written in the base you choose for it, printing the result in all four bases too. Every figure is held as an exact 64-bit integer, so the digits you see are the digits you typed, however large the number is.

Worked Example

Take the decimal number 255. In binary it is 11111111, because 255 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 — eight set bits. In octal it is 377, because 3 × 64 + 7 × 8 + 7 = 255. In hexadecimal it is ff, because 15 × 16 + 15 = 255. Now add the decimal 255 to the hexadecimal ff, which is also 255: the sum is 510, and it reads 111111110 in binary, 776 in octal and 1fe in hexadecimal. Both operands are parsed to the same magnitude before the addition, so the base each was typed in never affects the answer.

Real-World Usage

Use it to read a hexadecimal colour code or a memory address as a decimal, to check a binary mask or a permission bit, to see how many bits a decimal number needs, or to add and subtract values written in different bases — a hexadecimal register value and a decimal count, for example — without converting them by hand first.

Local Context

The four bases and the positional arithmetic are the same everywhere, so this page's content is not tied to any country. The one convention it states is its own: the accepted magnitude is capped at 64 unsigned bits (18,446,744,073,709,551,615), the largest value a 64-bit unsigned register holds, because that is a boundary a reader recognises and larger inputs are outside this page's use. Decimal digits are shown without an exponent, and hexadecimal digits in capitals for reading.

Last reviewed: October 2026.

Frequently Asked Questions

Why does hexadecimal exist?

Because sixteen is a power of two: one hexadecimal digit is exactly four bits, so a byte is always two hexadecimal digits. That makes hex a lossless shorthand for binary — 11111111 is ff, 10101100 is ac — and it is why memory addresses, colour codes and machine code are usually written in hex rather than in binary.

Why does the calculator refuse 0x and 0b prefixes?

Because every character is checked against the base you selected. In base 16 the letter x is not a digit, and in base 2 the letter b is not a digit, so 0xFF and 0b1010 are refused rather than guessed at. Choose the base in the control and type the digits alone: ff, or 1010.

What happens if I enter a fraction or an exponent?

It is refused. This page converts integers, so a decimal point or a fraction such as 1.5 is rejected, and so is scientific notation such as 1e3 in decimal. In base 16, though, the letter e is a genuine digit, so 1e3 there is the hexadecimal number 0x1E3 — 483 in decimal.

What happens when a subtraction goes below zero?

The result is printed as a signed negative magnitude: 1 − 2 gives -1, and its four representations are -1 in every base. Two's-complement form — the way a processor stores a negative number in a fixed number of bits — is not shown, because the width of the word it would be stored in is not part of the question.

Related Tools