Binary Calculator

Binary is the language a processor speaks: ones and zeros in base two, and the format of every hex dump and machine instruction. This page runs arithmetic on two decimal inputs and prints the answer in binary, alongside the bitwise AND, OR and XOR that compare numbers bit by bit. Refusals are part of the design — a negative result, a fraction or a division by zero each gets a plain message.

Enter values

Enter it in decimal (base 10); the answer comes back in binary

Results update as you type.

Results

Result in binary
10100
Result in decimal
20
Calculation
13 + 7 = 20

How is the Binary calculated?

Two number fields take the operands — both entered in ordinary decimal, each from 0 to 2,147,483,647 — and a menu picks the operation: add, subtract, multiply, divide, or the bitwise AND, OR and XOR. Three result rows follow: the answer in binary (emphasised), the answer in decimal, and the calculation written out as an equation. The edge cases answer honestly: 14 ÷ 4 reports that 3.5 is not a whole number, 13 − 20 says a negative has no plain binary form, and division by zero says so outright.

Formula

to binary: divide by 2 repeatedly and read the remainders upward — 20 → 10 r0, 5 r0, 2 r1, 1 r0, then the final 1, giving 10100

where AND keeps a bit set only when both operands set it, OR when either does, XOR when exactly one does. Operands stop at 2,147,483,647 (2³¹ − 1) so bitwise results stay inside 32-bit integers.

Example

13 + 7: 13 is 1101 in binary, 7 is 0111, and the sum 20 comes back as 10100, with the line 13 + 7 = 20 printed underneath. Bitwise, 13 AND 7 = 5 because only the low bits are shared (1101 & 0111 = 0101), while 13 XOR 7 = 10 flips exactly the positions that differ. The refusals carry equal weight: 14 ÷ 4 returns the decimal 3.5 but declines to binary, and 13 − 20 explains that a negative has no plain binary form.

Things to remember

Unsigned whole numbers only: counts, addresses and flags behave like this page, while two's complement and floating point follow other rules, so negatives and fractions are reported rather than invented. The equation row checks any answer by hand, and the number-base converter handles base conversions.

Frequently Asked Questions

How do you convert a decimal number to binary?

Divide by two repeatedly and read the remainders from the last step down to the first: 20 gives 10 r0, then 5 r0, 2 r1, 1 r0, and a final 1, which reads upward as 10100. This calculator performs those divisions for you and prints the binary result first, with the decimal working beside it.

Why can't the calculator show negative binary results?

It speaks unsigned binary, where there is no spare bit to mark a sign — representing −7 needs two's complement, a different notation with its own wraparound rules. So 13 − 20 shows the decimal −7 and an explanation, rather than a string that only readers of two's complement could interpret.

What do the AND, OR and XOR operators do?

They compare two numbers bit by bit: AND keeps a position only when both have a 1, OR when either does, XOR when exactly one does. With 13 (1101) and 7 (0111) that gives 0101 = 5 for AND, 1111 = 15 for OR and 1010 = 10 for XOR — the arithmetic behind masks, flags and permissions.

Why does my division answer refuse to show in binary?

Because plain binary encodes whole numbers only, and 14 ÷ 4 lands on 3.5 with no digit for the fractional part. The calculator reports the decimal 3.5 and declines the conversion. Round deliberately — or keep the remainder — whenever an integer answer is what the surrounding system expects.

More Technology & Data calculators

See all 5 Technology & Data calculators