Binary Calculator

Binary is the fundamental language of computers, encoding every piece of data as sequences of 0s and 1s. This calculator handles two essential tasks: base conversion (binary, decimal, hex, octal with ASCII display) and binary arithmetic (addition, subtraction, multiplication, division, plus bitwise AND, OR, XOR, and NOT). It supports unsigned integers and two's complement signed representation in 8, 16, and 32-bit widths, and shows carry-bit details for addition so you can follow each step of the computation.

star 4.8
New

Binary Calculator calculator

Input
Binary (Base 2)
11111111
Decimal (Base 10)
255
Hex (Base 16)
FF
Octal (Base 8)
377
Bit Visualization

How to Use the Binary Calculator

1

Choose a mode

Select Conversion to translate between number bases, or Arithmetic to perform binary operations.

2

Enter your number

Type a number and select its base (binary, decimal, hex, or octal).

3

View results

See the converted value in all bases, or the arithmetic result with step-by-step binary working.

The Formula

To convert binary to decimal, multiply each bit by 2 raised to its position and sum the results. For example, 1011 = 1x8 + 0x4 + 1x2 + 1x1 = 11.

Value = sum(digit * base^position)

lightbulb Variables Explained

  • digit Each digit in the number (0 or 1 for binary)
  • base The number system base (2 for binary)
  • position Position from right, starting at 0

tips_and_updates Pro Tips

1

Each hex digit maps to exactly 4 binary bits, making hex-to-binary conversion straightforward

2

Two's complement flips all bits and adds 1 to represent negative numbers

3

Binary addition follows the same column rules as decimal: 1+1 = 10 (carry the 1)

4

Use bit widths (8/16/32) to see how numbers are stored in actual computer memory

5

AND, OR, XOR operate bit-by-bit and are fundamental to digital logic design

Convert numbers between binary, decimal, hexadecimal, and octal instantly. Perform binary addition, subtraction, multiplication, division, and bitwise operations with full step-by-step explanations. Supports unsigned and two's complement signed representation in 8, 16, and 32-bit widths.

Binary to Decimal Conversion

Binary (base 2) uses only digits 0 and 1. To convert to decimal, multiply each bit by 2 raised to its position power and sum the results.

Example: 10110 = 16+4+2 = 22.

Binary Arithmetic Operations

Binary addition, subtraction, multiplication, and division follow the same principles as decimal arithmetic but with only two digits.

This calculator shows carries, borrows, and partial products step by step.

Bitwise Operations & Two's Complement

Bitwise AND, OR, XOR, and NOT operate on individual bits and are fundamental to computing.

Two's complement representation allows negative numbers in binary, with the most significant bit indicating the sign.

How to Convert Decimal to Binary Step by Step

To convert a decimal number to binary, repeatedly divide it by 2 and record each remainder, then read the remainders from bottom to top.

For example, 22 becomes: 22/2=11 R0, 11/2=5 R1, 5/2=2 R1, 2/2=1 R0, 1/2=0 R1, giving 10110.

Binary is the base-2 positional system defined in international standard ISO/IEC/IEEE 60559 and ISO 80000-1, where each position represents a power of 2.

Because computers store all data as two-state signals, base-2 is the natural encoding, and this remainder method reliably converts any non-negative integer into its binary form.

How to Convert Binary to Hexadecimal and Octal

To convert binary to hexadecimal, group the bits into sets of 4 from the right and map each group to one hex digit (0000=0 through 1111=F); for octal, group into sets of 3 (000=0 through 111=7).

For example, binary 11111111 = FF in hex and 377 in octal.

This works because 16 = 2^4 and 8 = 2^3, so each hex digit encodes exactly 4 bits and each octal digit exactly 3 bits.

The hexadecimal and octal notations are standardized in ISO/IEC 9899 (the C language standard), making them compact shorthands widely used by programmers to read long binary strings.

How to Calculate Two's Complement for Negative Numbers

To find the two's complement of a binary number, invert every bit (one's complement) and then add 1.

For example, in 8 bits, +5 is 00000101, so -5 is 11111010 + 1 = 11111011.

Two's complement is the standard signed-integer representation described in ISO/IEC 9899 and used by virtually every modern processor because addition and subtraction work identically for signed and unsigned values.

The value range depends on the bit width:

  • In an 8-bit width, values range from -128 to 127
  • In 16-bit, -32,768 to 32,767
  • In 32-bit, roughly -2.15 billion to 2.15 billion

The most significant bit acts as the sign bit.

Why Computers Use Binary Instead of Decimal

Computers use binary because electronic circuits reliably distinguish just two states, on and off, mapped to 1 and 0.

This two-level signaling tolerates noise far better than trying to hold ten distinct voltage levels for decimal, so binary underpins the digital logic and memory described in IEEE and ISO/IEC computing standards. Every character, image, and instruction is ultimately stored as bits.

The International Electrotechnical Commission (IEC 80000-13) formalizes the bit as the fundamental unit of information and the byte as 8 bits, which is why data sizes and memory addresses are expressed in powers of 2 throughout computer architecture.

Bits, Bytes, and Data-Size Prefixes (KiB vs kB)

One byte equals 8 bits, and data sizes use two different prefix systems.

Binary prefixes defined by IEC 80000-13 use powers of 1024:

  • 1 KiB (kibibyte) = 1024 bytes
  • 1 MiB = 1024 KiB
  • 1 GiB = 1024 MiB

Decimal SI prefixes from BIPM use powers of 1000:

  • 1 kB = 1000 bytes
  • 1 MB = 1,000,000 bytes

This distinction explains why a drive labeled 1 TB (10^12 bytes) shows as roughly 0.909 TiB in operating systems that count in powers of 1024. Using KiB/MiB avoids this ambiguity, which is why the IEC introduced the binary prefixes.

Common Real-World Uses of Binary Numbers

Binary powers nearly every digital technology:

  • Bitwise flags and masks pack many on/off settings into a single integer, saving memory in software and embedded systems.
  • Networking uses binary to compute subnet masks and IP address ranges, where each IPv4 octet is 8 bits.
  • Character encodings such as UTF-8, standardized by the Unicode Consortium, store text as byte sequences, and file formats, color values (24-bit RGB), and machine instructions are all binary.
  • Cryptography relies heavily on the XOR operation.

Understanding binary conversion and arithmetic helps programmers, network engineers, and hardware designers reason about how data is actually represented and manipulated.

How to Add and Subtract Binary Numbers by Hand

Binary addition follows four rules, column by column from right to left:

  • 0+0=0
  • 0+1=1
  • 1+0=1
  • 1+1=10 (write 0, carry 1); three 1s give 11 (write 1, carry 1)

For example, 1011 + 1101 = 11000, matching 11 + 13 = 24 in decimal.

Subtraction uses borrowing, where 0-1 borrows from the next column to make 10-1=1. In practice, most computers subtract by adding the two's complement, which avoids a separate borrow circuit.

This calculator displays each carry and borrow bit so you can verify the arithmetic step by step.

Common Binary Conversion Mistakes to Avoid

Several errors trip people up when working with binary:

  • The most frequent error is reading remainders in the wrong order during decimal-to-binary conversion; always read them bottom to top.
  • Another is miscounting bit positions, which start at 0 on the right, not 1.
  • When grouping for hex or octal, pad with leading zeros from the left so the leftmost group is complete.
  • With two's complement, forgetting the fixed bit width causes sign errors, since -5 differs in 8-bit versus 16-bit form.
  • Finally, confusing binary prefixes (1 KiB = 1024 bytes per IEC 80000-13) with decimal prefixes (1 kB = 1000 bytes per BIPM) leads to storage-size miscalculations.

Frequently Asked Questions

sell

Tags