Full Guide

Binary Calculator Guide

Learn base conversion across binary, octal, decimal, and hexadecimal, plus binary arithmetic and AND, OR, XOR operations with their input and numeric limits.

Open calculator

Full Guide

What This Calculator Does

The Binary Calculator covers two distinct search intents:

  • Base conversion: enter one non-negative integer and its base, then rewrite it as binary (BIN), octal (OCT), decimal (DEC), and hexadecimal (HEX). For example, decimal 42 becomes binary 101010, octal 52, and hexadecimal 2A.
  • Binary operations: enter two binary integers, choose +, , ×, ÷, AND, OR, or XOR, and read the result in binary and decimal.

It is useful for learning number bases, checking bitmasks, and doing quick integer verification. It is not a signed-format, floating-point, arbitrary-precision, or full programmer-calculator replacement.

When to Use It

  • You want to confirm that 42, 101010, 52, and 2A represent the same integer.
  • You are learning binary addition, subtraction, multiplication, integer division, or bitwise logic.
  • You need to check an AND, OR, or XOR mask.
  • You want both the bit pattern and the decimal magnitude in one result.

Inputs Explained

Convert Mode

Choose the input base and enter one non-negative integer. Binary accepts 0–1, octal accepts 0–7, decimal accepts 0–9, and hexadecimal accepts 0–9 plus A–F. Hexadecimal letters are case-insensitive and are displayed in uppercase.

The input field does not parse 0b, 0o, or 0x prefixes, signs, decimal points, spaces, commas, or scientific notation. It expects a digit string for one integer, not a complete JavaScript or Python numeric literal.

Binary Operations Mode

Operands A and B may contain only 0 and 1. The selected operator determines the calculation:

  • +, , ×: ordinary integer arithmetic.
  • ÷: a floored integer quotient for non-negative integers.
  • AND: keeps a bit set only when both positions are 1.
  • OR: keeps a bit set when either position is 1.
  • XOR: keeps a bit set when the two positions differ.

Keep bitwise operands within 32 bits because the underlying JavaScript bitwise operators use signed 32-bit semantics.

How the Calculation Works

For a base-b integer written as dₙdₙ₋₁...d₀, its value is:

[ \sum_{i=0}^{n}d_i b^i ]

Convert mode parses the value as a JavaScript integer and renders the same value in bases 2, 8, 10, and 16. The four conversion cards are four representations of one value, not four independent answers.

Calculate mode parses both binary strings as integers and applies the selected operation. Addition, subtraction, and multiplication return integer results; division uses Math.floor(A/B). AND, OR, and XOR follow JavaScript's signed 32-bit bitwise behavior, so high bits can affect the sign and inputs longer than 32 bits can be truncated.

Mode, input base, values, operands, and operator are stored in URL parameters so a shared link can restore the same inputs. Copy buttons copy the displayed value only.

Example

Convert one decimal integer

In convert mode, choose decimal and enter 42:

[ 42_{10}=101010_2=52_8=2A_{16} ]

The BIN, OCT, DEC, and HEX cards show these four forms.

Binary addition

Enter A=1010, B=0110, and choose +:

[ 1010_2+0110_2=10000_2=16_{10} ]

AND, OR, and XOR

For 1010 and 0110:

[ 1010\ \text{AND}\ 0110=0010_2=2_{10} ]

The page omits insignificant leading zeros and normally displays the binary result as 10, with decimal result 2. With the same operands, OR gives 1110 (14) and XOR gives 1100 (12).

Integer division and negative subtraction

For 1011 ÷ 0010, the decimal calculation is 11 ÷ 2; the page returns integer quotient 5, binary 101, and no remainder.

For 0010 − 0101, the decimal result is -3 and the binary string is -11. This is not fixed-width two's-complement output; use a programmer calculator when you need width, signed/unsigned interpretation, or complement notation.

How to Understand the Result

  • BIN / OCT / DEC / HEX: four representations of the same converted value in bases 2, 8, 10, and 16.
  • Operation Expression: the two operands and selected operator, shown again for input checking.
  • Binary Result: best for inspecting the bit pattern; it may omit leading zeros or include - for a negative arithmetic result.
  • Decimal Result: best for checking ordinary integer magnitude; high-bit AND, OR, or XOR results may appear negative under signed 32-bit semantics.

Do not confuse the string 1010 with decimal 1010; the same characters represent different values in different bases.

Common Mistakes

  • Entering 2 in a binary field or 8 in an octal field.
  • Pasting 0x2A, 0b101010, or -42 into convert mode.
  • Entering decimal characters in calculate mode instead of a 0/1 string.
  • Expecting division to show a decimal fraction or remainder.
  • Treating an AND, OR, or XOR calculation on more than 32 bits as an arbitrary-length bit-string operation.
  • Using values beyond JavaScript's safe-integer range for exact verification.

FAQ

Are 101010 and 42 the same number?

Yes, when the first is read as binary and the second as decimal: 101010₂=42₁₀. Always confirm the selected input base.

Can hexadecimal input use lowercase letters?

Yes. The input is normalized to uppercase for display, so a and A represent the same hexadecimal digit.

Why are leading zeros missing from the result?

The page uses the shortest ordinary representation rather than padding every result to 8, 16, or 32 bits. Leading zeros change formatting, not value.

How are bitwise operations different from addition?

Addition creates carries and changes the overall numeric value. AND, OR, and XOR compare corresponding bits, so their results usually differ even when the inputs look similar.

Is this an arbitrary-precision or two's-complement tool?

No. It is intended for ordinary integer learning and quick checks. Arbitrary precision, fixed 8/16/32/64-bit widths, signed/unsigned switching, NOT, shifts, and remainders require a more specialized tool.

Notes

This page accepts non-negative integer base conversion and binary-string operations. Conversion and arithmetic use JavaScript Number, so values beyond the safe-integer range can lose precision. AND, OR, and XOR use signed 32-bit bitwise operations, so inputs longer than 32 bits should not be treated as a complete arbitrary-length bit string.

It does not support decimals, negative convert-mode inputs, 0b/0o/0x prefixes, fixed-width complements, signed/unsigned switching, NOT, left/right shifts, remainders, floating-point binary, arbitrary-precision integers, or per-bit carry animation. For broader numeric expressions, try the Mathematical Expression Calculator; for related integer work, see the Absolute Value Calculator, Significant Figures Calculator, and Decimal Fraction Converter.

Frequently Asked Questions

What does this page support?

It supports single-value conversion among binary, octal, decimal, and hexadecimal, plus addition, subtraction, multiplication, division, AND, OR, and XOR for two binary integers.

Can I enter a 0b, 0x, or negative-number prefix?

No. Convert mode accepts the non-negative integer characters for the selected base, and calculate mode accepts binary strings made only of 0 and 1.

Why does binary division have no decimal part?

The current implementation uses a floored integer quotient for non-negative integers; it does not display a fractional part or a remainder card.

Do AND, OR, and XOR support any length?

Not safely. They follow JavaScript's 32-bit signed bitwise semantics, so inputs longer than 32 bits may be truncated; keep bitwise operands within 32 bits.

Are very large base values exact?

The page parses integers through JavaScript Number, so very long values beyond the safe-integer range can lose precision and are not suitable for arbitrary-precision work.