Binary Calculator

Convert decimal to binary, hex, and octal instantly. Perform binary addition, subtraction, and more. Free online binary calculator, 2026.

Reviewed by CalculatorApp.me Math Team

Binary Calculator โ€” Complete Guide

Convert between binary, decimal, hexadecimal, and octal. Understand bitwise operations, two's complement, and how computers represent data.

0 & 1

Two binary digits

2โธ = 256

One byte range

IEEE 754

Float standard

UTF-8

Text encoding

Understanding Binary (Base 2)

The binary number system (base 2) uses only two digits: 0 and 1. Each digit (called a bit) represents a power of 2. Binary is the foundation of all digital computing โ€” processors, memory, storage, and networking all operate on binary data.

In the decimal system (base 10), the number 347 means 3ร—10ยฒ + 4ร—10ยน + 7ร—10โฐ. Similarly, in binary, 1101โ‚‚ means 1ร—2ยณ + 1ร—2ยฒ + 0ร—2ยน + 1ร—2โฐ = 8 + 4 + 0 + 1 = 13โ‚โ‚€.

Grouping bits creates larger units: 4 bits = a nibble (0โ€“15), 8 bits = a byte (0โ€“255), 16 bits = a word (historical), 32 bits = a dword, 64 bits = a qword. Modern processors work with 64-bit integers natively, handling values up to 2โถโด โˆ’ 1 = 18,446,744,073,709,551,615.

Number Base Conversions

Decimal โ†’ Binary
Repeated Division by 2:

  42 รท 2 = 21  remainder 0
  21 รท 2 = 10  remainder 1
  10 รท 2 = 5   remainder 0
  5  รท 2 = 2   remainder 1
  2  รท 2 = 1   remainder 0
  1  รท 2 = 0   remainder 1

  Read remainders bottomโ†’top:
  42โ‚โ‚€ = 101010โ‚‚

Verify: 32+0+8+0+2+0 = 42 โœ“

For fractions:
  0.625 ร— 2 = 1.25  โ†’ 1
  0.25  ร— 2 = 0.5   โ†’ 0
  0.5   ร— 2 = 1.0   โ†’ 1
  0.625โ‚โ‚€ = 0.101โ‚‚

The repeated-division method works for any base conversion. For fractions, multiply by the target base instead and read integer parts topโ†’bottom.

Binary โ†’ Hex (Base 16)
Group bits into nibbles (4 bits):

Binary:  1010  1111  0011  1100
Hex:      A     F     3     C

  0000=0  0100=4  1000=8  1100=C
  0001=1  0101=5  1001=9  1101=D
  0010=2  0110=6  1010=A  1110=E
  0011=3  0111=7  1011=B  1111=F

Examples:
  1111 1111โ‚‚ = FFโ‚โ‚† = 255โ‚โ‚€
  0001 0000โ‚‚ = 10โ‚โ‚† = 16โ‚โ‚€
  1100 1010โ‚‚ = CAโ‚โ‚† = 202โ‚โ‚€

Hex is compact representation:
  32-bit address in binary: 32 chars
  Same in hex: only 8 chars
  0xDEADBEEF = 11011110...

Hexadecimal is the standard shorthand for binary data. Memory addresses, color codes (#FF5733), MAC addresses (AA:BB:CC:DD:EE:FF), and debug output all use hex.

Binary โ†’ Octal (Base 8)
Group bits into triplets (3 bits):

Binary:  101  010  111  100
Octal:    5    2    7    4

  000=0  010=2  100=4  110=6
  001=1  011=3  101=5  111=7

Examples:
  111 111 111โ‚‚ = 777โ‚ˆ = 511โ‚โ‚€
  001 000โ‚‚     = 10โ‚ˆ  = 8โ‚โ‚€

Unix File Permissions (octal):
  chmod 755 = rwxr-xr-x
  7 = 111โ‚‚ = rwx (read+write+exec)
  5 = 101โ‚‚ = r-x (read+exec)
  4 = 100โ‚‚ = r-- (read only)
  0 = 000โ‚‚ = --- (no permissions)

Octal (base 8) maps cleanly to 3-bit groups. Its primary modern use is Unix file permissions: 644, 755, 777 are all octal representations of 9-bit permission sets.

IEEE 754 Floating Point
32-bit float layout:
โ”Œโ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚Sโ”‚ Exponent โ”‚     Mantissa          โ”‚
โ”‚1โ”‚ 8 bits   โ”‚     23 bits           โ”‚
โ””โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Value = (-1)หข ร— 1.mantissa ร— 2^(exp-127)

Example: 6.5โ‚โ‚€
  6.5 = 110.1โ‚‚ = 1.101 ร— 2ยฒ
  Sign: 0 (positive)
  Exponent: 2 + 127 = 129 = 10000001โ‚‚
  Mantissa: 10100000000000000000000

  Full: 0 10000001 10100000000000000000000
  Hex:  0x40D00000

Special values:
  0 00000000 000...0 = +0
  0 11111111 000...0 = +โˆž
  0 11111111 1xx...x = NaN

64-bit double: 1+11+52 bits
  Precision: ~15-16 decimal digits

IEEE 754 (1985) standardized floating-point arithmetic worldwide. The infamous 0.1 + 0.2 โ‰  0.3 is because 0.1 has an infinite binary expansion, causing unavoidable rounding.

Bitwise Operations

OperationSymbolExample (Binary)ResultUse Case
AND&1100 & 10101000Masking bits, checking flags
OR|1100 | 10101110Setting flags, combining masks
XOR^1100 ^ 10100110Toggle bits, encryption, swap
NOT~~11000011Invert all bits (one's complement)
Left Shift<<0011 << 21100Multiply by 2โฟ (fast power of 2)
Right Shift>>1100 >> 20011Divide by 2โฟ (integer division)
Unsigned Right Shift>>>1100 >>> 10110Shift with zero-fill (no sign extend)

Bitwise operations work directly on integer bit patterns. They are common in masks, flags, binary formats, device interfaces, compression, and graphics code; actual performance depends on the language, compiler, and processor.

Two's Complement (Signed Integers)

Binary (8-bit)Unsigned ValueSigned ValueNotes
0000 000000Zero
0000 00011+1Smallest positive
0111 1111127+127Largest positive (signed 8-bit)
1000 0000128โˆ’128Most negative (signed 8-bit)
1111 1110254โˆ’2Invert bits of 2, add 1
1111 1111255โˆ’1All bits set
โ€”0 to 255โˆ’128 to +1278-bit range comparison

To negate in two's complement: flip all bits (NOT), then add 1. Example: +5 = 00000101 โ†’ flip โ†’ 11111010 โ†’ add 1 โ†’ 11111011 = โˆ’5. This system makes addition/subtraction hardware identical for signed and unsigned numbers.

Data Types & Storage Sizes

TypeBitsUnsigned RangeSigned RangeCommon Use
byte / int880 โ€“ 255โˆ’128 to 127Pixel channels, ASCII
short / int16160 โ€“ 65,535โˆ’32,768 to 32,767Audio samples, sensor data
int / int32320 โ€“ 4.29ร—10โนโˆ’2.15ร—10โน to 2.15ร—10โนLoop counters, IDs
long / int64640 โ€“ 1.84ร—10ยนโนโˆ’9.22ร—10ยนโธ to 9.22ร—10ยนโธTimestamps, file sizes
float3232ยฑ1.18ร—10โปยณโธ to ยฑ3.4ร—10ยณโธ~7 decimal digitsGPU, ML weights
float64 (double)64ยฑ2.2ร—10โปยณโฐโธ to ยฑ1.8ร—10ยณโฐโธ~15 decimal digitsScientific, financial

History of Binary Numbers

~300 BC

Pingala โ€” Binary in Indian Prosody

The Indian mathematician Pingala used a binary-like system (laghu/guru, short/long syllables) to classify Sanskrit meters. His Chandaแธฅล›ฤstra describes a system equivalent to binary numbers, predating Leibniz by nearly 2,000 years.

1703

Leibniz โ€” Formal Binary System

Gottfried Wilhelm Leibniz published 'Explication de l'Arithmรฉtique Binaire', the first formal description of the binary number system. He demonstrated all arithmetic (addition, subtraction, multiplication, division) in base 2. He was inspired by the Chinese I Ching hexagrams.

1854

Boole โ€” Boolean Algebra

George Boole published 'An Investigation of the Laws of Thought', creating Boolean algebra. His binary logic (TRUE/FALSE, 1/0) with AND, OR, NOT operations became the mathematical foundation for all digital circuits and computer science.

1937

Shannon โ€” Boolean Logic in Circuits

Claude Shannon's MIT master's thesis showed that Boolean algebra could be implemented with electrical relay circuits. This breakthrough connected Boole's abstract mathematics to physical hardware, making digital computers possible.

1945

Von Neumann โ€” Binary Computer Architecture

John von Neumann's EDVAC report described a stored-program computer using binary arithmetic and memory. The von Neumann architecture โ€” where both programs and data are stored in binary memory โ€” remains the basis of virtually all modern computers.

1985

IEEE 754 โ€” Floating-Point Standard

The IEEE published Standard 754 for floating-point arithmetic, standardizing how computers represent real numbers in binary. This eliminated incompatibilities between hardware vendors and established the 32-bit float / 64-bit double formats used universally today.

Key Research & Data

Myths vs. Facts

โœ•

Computers 'think' in binary โ€” they understand 0s and 1s.

โœ“

Computers don't 'understand' anything. They're physical circuits where voltage levels (e.g., 0V vs 5V) represent 0 and 1. Transistors switch on/off โ€” no comprehension involved. Binary is the mathematical abstraction we use to describe electrical states.

โœ•

1 KB = 1000 bytes.

โœ“

Historically, 1 KB = 1024 bytes (2ยนโฐ) because binary powers are natural for computers. The IEC standard introduced KiB (kibibyte) = 1024 bytes vs. KB (kilobyte) = 1000 bytes to resolve ambiguity. Storage manufacturers use 1000; RAM uses 1024.

โœ•

Binary is too limited since it only has two digits.

โœ“

Binary can represent ANY information: all numbers, text, images, video, and programs are encoded in binary. Two digits is sufficient because position provides the complexity โ€” 64 binary digits can represent 2โถโด โ‰ˆ 1.8ร—10ยนโน distinct values.

โœ•

Floating-point numbers are always accurate in binary.

โœ“

Many decimal fractions have infinite binary representations (e.g., 0.1โ‚โ‚€ = 0.0001100110011...โ‚‚ repeating). This causes the infamous 0.1 + 0.2 = 0.30000000000000004 issue. For exact decimal arithmetic (finance), use integer cents or dedicated decimal libraries.

Frequently Asked Questions

How do I convert decimal to binary?โ–ผ
Divide the number by 2 repeatedly, recording remainders. Read remainders from bottom to top. Example: 25 โ†’ 25รท2=12r1, 12รท2=6r0, 6รท2=3r0, 3รท2=1r1, 1รท2=0r1 โ†’ 11001โ‚‚. For fractions, multiply by 2 and read integer parts top to bottom.
What is a byte?โ–ผ
A byte is 8 bits โ€” the standard addressable unit of memory. It can represent values 0โ€“255 (unsigned) or โˆ’128 to 127 (signed). One byte stores one ASCII character. The prefix 'kilo-' in kilobyte means either 1000 or 1024 bytes depending on context.
What are hexadecimal numbers?โ–ผ
Hexadecimal (base 16) uses digits 0-9 and letters A-F (10-15). Each hex digit maps to exactly 4 binary bits, making it a compact notation for binary data. Example: 0xFF = 1111 1111โ‚‚ = 255โ‚โ‚€. Used for colors (#FF5733), memory addresses, debug output.
Why do computers use binary instead of decimal?โ–ผ
Transistors are most reliable as switches (on/off = 1/0). Binary circuits are simple, fast, and noise-resistant. A decimal circuit would need 10 distinct voltage levels per digit โ€” vastly more complex and error-prone. Binary's simplicity enabled the miniaturization that created modern computing.
What is two's complement?โ–ผ
The standard method for representing negative integers in binary. To negate: flip all bits and add 1. Advantages: only one representation of zero, and addition hardware works identically for positive and negative numbers. Used by all modern processors.
What does 0.1 + 0.2 โ‰  0.3 mean in binary?โ–ผ
The decimal 0.1 has an infinite repeating binary representation (0.000110011...). When stored in finite bits (IEEE 754 double), it's rounded. Adding two rounded values produces 0.30000000000000004 instead of exactly 0.3. This affects ALL languages using IEEE 754.
What is Big Endian vs Little Endian?โ–ผ
Byte order in multi-byte values. Big Endian: most significant byte first (0x12345678 stored as 12 34 56 78). Little Endian: least significant first (78 56 34 12). x86/ARM use Little Endian; network protocols use Big Endian (network byte order).
How do binary operations work in programming?โ–ผ
Languages like C, JavaScript, Python support bitwise operators: & (AND), | (OR), ^ (XOR), ~ (NOT), << (left shift), >> (right shift). These operate on individual bits and are used for flags, masks, compression, hashing, and performance optimization.
What is ASCII vs Unicode?โ–ผ
ASCII (1963) maps 128 characters to 7-bit binary codes (A=65=1000001โ‚‚). Unicode (1991) extends this to 154,998+ characters covering all scripts. UTF-8 encoding uses 1-4 bytes per character and is backward-compatible with ASCII. Over 98% of websites use UTF-8.
How does binary relate to logic gates?โ–ผ
Logic gates (AND, OR, NOT, XOR, NAND, NOR) process binary signals physically. An AND gate outputs 1 only if both inputs are 1. Billions of gates combined create processors, memory, and all digital hardware. Every computation reduces to logic gate operations on binary values.
What is BCD (Binary-Coded Decimal)?โ–ผ
BCD encodes each decimal digit in 4 binary bits: 9 = 1001, 42 = 0100 0010. Unlike pure binary, BCD preserves decimal digit boundaries. Used in financial calculators, clocks, and systems requiring exact decimal representation. Less space-efficient than pure binary.
What are binary file formats?โ–ผ
Binary files store data as raw bytes rather than human-readable text. Examples: images (PNG, JPEG), audio (MP3, WAV), executables (.exe, ELF), databases. Binary formats are more compact and faster to parse than text formats but require specific software to read.

References

Related Calculators

Explore All Math Calculators

Binary conversions, bitwise operations, and number systems โ€” CalculatorApp.me.

Browse Math Calculators โ†’

Binary Calculator โ€” Answer & Method

Convert between binary, decimal, octal, and hexadecimal number systems with arithmetic operations.

Formula: Binary to Decimal

Decimal = ฮฃ(bit ร— 2^position)

b = Binary Digits

Example Calculation

11010โ‚‚ = 16+8+2 = 26โ‚โ‚€ = 1Aโ‚โ‚† = 32โ‚ˆ.

Important limitation

Check the result against your specific circumstances before making a decision.

Key Facts

  • Computers use binary (base-2) because digital circuits have two states: on and off.

Sources & Validation

IEEE 754Computer Science fundamentals

Related Calculators

Deterministic: YesAI-Generated Numbers: NoVerified: 2026-02-12

Related Articles

See Also