Add, subtract, multiply, divide and run bitwise AND, OR, XOR, NOT and shifts on binary, octal, decimal or hexadecimal numbers, with the result in every base. Free, runs in your browser.

RT-MAT-026 · Mathematics
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

Binary Calculator

📅 Research current as of 13 Sep 2026 · Sources: ECMA-262 (17th ed., 2026) §6.1.6.2 BigInt operations; Knuth, TAOCP Vol. 2, 3rd ed. §4.1; Warren, Hacker's Delight, 2nd ed.
Standards, published formulas, and reference data are revised over time — check against a current authoritative source before relying on these figures.
Advertisement
After tool · AD-W1Responsive · Post-tool

How to Use the Binary Calculator

Enter two numbers

Type operand A and operand B, and set the base of each — binary, octal, decimal or hexadecimal. You can mix bases freely, such as a hex A with a binary B.

Choose an operation

Pick arithmetic (add, subtract, multiply, divide, modulo) or a bitwise operation (AND, OR, XOR, NOT, or a left or right shift). Division is integer division — the quotient is truncated toward zero and A mod B returns the remainder, which carries the sign of A.

Read every base

The result appears at once in binary, decimal, hexadecimal and octal, with the binary grouped into nibbles for readability.

Work with any size

The calculator uses arbitrary-precision integers, so even very large numbers stay exact — there is no 32-bit or 64-bit overflow on the arithmetic.

Advertisement
After how-to · AD-W2Responsive

Binary: How Computers Count

Base Two and Its Friends

Everyday numbers are written in base ten — ten digits, 0 through 9, with each place worth ten times the one to its right. Computers use base two, or binary, with just two digits, 0 and 1, because those map perfectly onto the two states of a switch: off and on, low voltage and high. Every number, letter, image and instruction inside a machine is ultimately a pattern of these bits. Binary is verbose for humans, though, so two shorthand bases ride alongside it: octal (base eight) groups bits in threes, and hexadecimal (base sixteen) groups them in fours, which is why a single hex digit captures exactly four bits and a byte is two hex digits. This calculator works in all four bases at once — type a number in any of them and see the result in every base, so you can move between the human-friendly decimal and the machine-friendly binary and hex without converting by hand. It performs ordinary arithmetic and the bitwise operations that are the real native language of a processor.

Bitwise operations act on the individual bits of a number rather than its value as a whole, and they are everywhere in low-level programming. AND keeps only the bits set in both numbers, which is how a program masks out the parts of a value it cares about; OR sets a bit if it is on in either number, used to combine flags; XOR flips bits that differ, the basis of simple encryption, checksums and the trick for swapping two values without a temporary. NOT inverts every bit, and because that depends on how wide the number is, this calculator lets you choose an 8-, 16-, 32- or 64-bit width for it. Shifting moves all the bits left or right, which multiplies or divides by powers of two — a left shift by one doubles a number, a right shift halves it (rounding down), which is why compilers rewrite a multiplication by a power of two as a shift. These operations are how device drivers talk to hardware, how graphics code packs colours into a single integer, and how cryptography and compression squeeze performance out of every cycle. Everything here is computed with arbitrary-precision integers in your browser, so the numbers stay exact at any size.

"A byte is just eight switches. Binary, octal and hexadecimal are three ways of reading the same row of switches — and bitwise operations are how a processor flips them."

Why Bits Matter Beyond Programming

The reach of binary goes well past writing code. Network engineers read IP addresses and subnet masks in binary to see which addresses belong to a network — a calculation that is literally a bitwise AND. File formats and protocols pack many small fields into a single number using shifts and masks, so understanding bitwise operations is how you decode them. Permissions on a Unix system, the familiar 755 or 644, are octal precisely because each group of three permission bits fits one octal digit. Colours on the web are hexadecimal because each pair of hex digits is one byte of red, green or blue. Even outside computing, base conversion sharpens number sense: seeing that 255 is 11111111 in binary and FF in hex, that powers of two line up with round binary numbers, and that a shift is just a multiplication, builds the intuition behind how digital systems represent the world. Whether you are studying computer science, debugging low-level code, working with networks, or simply curious how machines count, this calculator gives you exact results across all four bases instantly and privately.

One hex digit is four bits, and XOR swaps without a temporary

01

Binary uses only 0 and 1 — matching a switch's off and on.

02

A byte is 8 bits and holds values from 0 to 255.

03

One hex digit equals exactly four binary digits.

04

A left shift by one doubles a number; a right shift halves it.

05

XOR can swap two numbers without a temporary variable.

06

A subnet mask is applied with a bitwise AND.

07

Unix file permissions like 755 are written in octal.

08

Web colours like #FF8800 are three hexadecimal bytes.

09

The decimal 255 is 11111111 in binary and FF in hex.

10

This calculator uses arbitrary precision — no overflow at any size.

Frequently Asked Questions

  • Yes. Each operand has its own base selector, so you can, for example, AND a hexadecimal A with a binary B. The calculator converts both to their true value, applies the operation, and shows the result in binary, decimal, hexadecimal and octal at once.
  • AND compares the two numbers bit by bit and keeps a 1 only where both have a 1. It is used to "mask" a value — to isolate certain bits and zero out the rest — and applying a subnet mask to an IP address is exactly a bitwise AND.
  • NOT flips every bit, but the answer depends on how many bits you are considering — flipping within 8 bits gives a different number than within 32 bits. So when you choose NOT, the calculator asks for a width (8, 16, 32 or 64 bits) and inverts the low w bits of the value, i.e. it returns (2w − 1) XOR A — the one's complement, so NOT 1010 at 8 bits is 1111 0101 (245). Enter an operand that fits the width: bits above it are left unchanged rather than flagged, so NOT 256 at 8 bits shows 511, not 255.
  • They are the same thing in binary. Shifting all the bits left by one position doubles the number, and by n positions multiplies it by 2 to the power n; shifting right divides by powers of two, discarding the remainder (10 >> 1 = 5, 11 >> 1 = 5). A shift is a single, simple processor instruction, which is why compilers substitute one for a multiplication by a power of two.
  • No. The arithmetic uses arbitrary-precision integers, so adding or multiplying very large binary or hexadecimal numbers stays exact with no 32-bit or 64-bit overflow. The optional width applies only to the NOT operation, where it is mathematically required.
  • They are compact stand-ins for binary. Each octal digit represents three bits and each hexadecimal digit represents four, so long binary strings become short and readable. That is why colours are written in hex and Unix permissions in octal.
  • Yes — enter your number as operand A, set its base, and leave the operation on something like "A + B" with B set to 0. The result row then shows your number in all four bases. For dedicated conversion, the Number Base Converter is also available.
  • No. Every calculation runs in your browser using native arbitrary-precision integers — nothing is uploaded to a server or third-party library, and the tool works offline once the page has loaded.
  • Bitwise operations on negative numbers depend on a chosen two's-complement width, which is ambiguous without one. To keep results clear and unambiguous, the calculator asks for non-negative operands on AND, OR, XOR and the shifts; ordinary arithmetic still handles negatives.
  • The integer quotient, truncated toward zero: 7 ÷ 2 shows 3 and −7 ÷ 2 shows −3, never a fraction. A mod B gives the remainder with the sign of A, so −7 mod 2 is −1 (not the +1 a mathematician's modulus would give). These are the ECMAScript BigInt rules, and they fit together: A = (A ÷ B) × B + (A mod B) always holds. For a fractional result use the Basic or Scientific Calculator.

Method & sources

How it computes

Arbitrary-precision integer arithmetic (+, −, ×, truncating ÷, remainder) and bitwise AND, OR, XOR, left and right shift on two operands each entered in base 2, 8, 10 or 16, with the result shown in all four bases; NOT A is the one's complement within a chosen width w ∈ {8, 16, 32, 64}: (2^w − 1) XOR A. Digits are parsed by positional (Horner) evaluation in the selected radix; bitwise operations and shifts accept non-negative operands only.

What this tool implements

  • ECMAScript BigInt semantics: division truncates toward zero and the remainder takes the sign of the dividend (−7 ÷ 2 = −3, −7 mod 2 = −1); shifts on non-negative values are exact multiplication / floor division by 2^n; no fixed word size, so arithmetic never overflows.
  • Positional notation with digit values 0–9, a–f (case-insensitive), underscores and spaces ignored as digit separators; binary output grouped in nibbles because one hexadecimal digit is exactly four bits and one octal digit three (Knuth TAOCP Vol. 2 §4.1).
  • NOT is the bitwise complement within the chosen width only (one's complement of the low w bits); bits above the width pass through unchanged, and negative operands are refused for bitwise operations because two's-complement bit patterns are undefined without a width — both stated on the page.
  • No floating point anywhere — every value is an exact integer.

Sources

  • Ecma International. ECMA-262: ECMAScript Language Specification. 17th ed. Geneva: Ecma International; 2026. §6.1.6.2 The BigInt Type — BigInt::divide, BigInt::remainder, BigInt::leftShift, BigInt::bitwiseAND/OR/XOR. https://ecma-international.org/publications-and-standards/standar…
  • Knuth DE. The Art of Computer Programming, Volume 2: Seminumerical Algorithms. 3rd ed. Reading, MA: Addison-Wesley; 1998. §4.1 Positional number systems (radix notation, complement representations), §4.4 Radix conversion.
  • Warren HS. Hacker's Delight. 2nd ed. Upper Saddle River, NJ: Addison-Wesley; 2013. Chapter 2, Basics: bitwise AND/OR/XOR identities, the XOR swap, shifts as multiplication and division by powers of two.

What can make this go out of date

  • None at runtime — exact integer arithmetic with no external data.
Advertisement
Pre-footer · AD-W3 728 × 90