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
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.
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.
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.
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
| Operation | Symbol | Example (Binary) | Result | Use Case |
|---|---|---|---|---|
| AND | & | 1100 & 1010 | 1000 | Masking bits, checking flags |
| OR | | | 1100 | 1010 | 1110 | Setting flags, combining masks |
| XOR | ^ | 1100 ^ 1010 | 0110 | Toggle bits, encryption, swap |
| NOT | ~ | ~1100 | 0011 | Invert all bits (one's complement) |
| Left Shift | << | 0011 << 2 | 1100 | Multiply by 2โฟ (fast power of 2) |
| Right Shift | >> | 1100 >> 2 | 0011 | Divide by 2โฟ (integer division) |
| Unsigned Right Shift | >>> | 1100 >>> 1 | 0110 | Shift 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 Value | Signed Value | Notes |
|---|---|---|---|
| 0000 0000 | 0 | 0 | Zero |
| 0000 0001 | 1 | +1 | Smallest positive |
| 0111 1111 | 127 | +127 | Largest positive (signed 8-bit) |
| 1000 0000 | 128 | โ128 | Most negative (signed 8-bit) |
| 1111 1110 | 254 | โ2 | Invert bits of 2, add 1 |
| 1111 1111 | 255 | โ1 | All bits set |
| โ | 0 to 255 | โ128 to +127 | 8-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
| Type | Bits | Unsigned Range | Signed Range | Common Use |
|---|---|---|---|---|
| byte / int8 | 8 | 0 โ 255 | โ128 to 127 | Pixel channels, ASCII |
| short / int16 | 16 | 0 โ 65,535 | โ32,768 to 32,767 | Audio samples, sensor data |
| int / int32 | 32 | 0 โ 4.29ร10โน | โ2.15ร10โน to 2.15ร10โน | Loop counters, IDs |
| long / int64 | 64 | 0 โ 1.84ร10ยนโน | โ9.22ร10ยนโธ to 9.22ร10ยนโธ | Timestamps, file sizes |
| float32 | 32 | ยฑ1.18ร10โปยณโธ to ยฑ3.4ร10ยณโธ | ~7 decimal digits | GPU, ML weights |
| float64 (double) | 64 | ยฑ2.2ร10โปยณโฐโธ to ยฑ1.8ร10ยณโฐโธ | ~15 decimal digits | Scientific, financial |
History of Binary Numbers
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.
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.
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.
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.
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.
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
Shannon (1948) โ Bell System Technical Journal
A Mathematical Theory of Communication
Shannon introduced the 'bit' as the fundamental unit of information: the amount of information in a binary choice. His information theory proved that any data can be encoded in binary with optimal efficiency. This paper founded the entire field of digital communications.
IEEE 754-2019 Standard
Floating-Point Arithmetic Standard
The updated IEEE 754 standard defines binary16, binary32, binary64, and binary128 formats used by every modern processor. It specifies rounding modes, special values (ยฑโ, NaN, ยฑ0), and exception handling. It enables portable numerical computing across all hardware.
Knuth โ The Art of Computer Programming Vol. 2
Seminumerical Algorithms (Binary Arithmetic)
Knuth's encyclopedic treatment of binary arithmetic provides the theoretical foundation for computer arithmetic: efficient multiplication (Karatsuba, FFT-based), division algorithms, floating-point gotchas, and random number generation โ all operating on binary representations.
Unicode Consortium โ Unicode Standard
Universal Character Encoding
Unicode assigns code points to characters across writing systems. UTF-8 encodes those code points in one to four bytes and remains backward-compatible with the 7-bit ASCII character set.
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?โผ
What is a byte?โผ
What are hexadecimal numbers?โผ
Why do computers use binary instead of decimal?โผ
What is two's complement?โผ
What does 0.1 + 0.2 โ 0.3 mean in binary?โผ
What is Big Endian vs Little Endian?โผ
How do binary operations work in programming?โผ
What is ASCII vs Unicode?โผ
How does binary relate to logic gates?โผ
What is BCD (Binary-Coded Decimal)?โผ
What are binary file formats?โผ
References
- Shannon โ A Mathematical Theory of Communication (1948)
- IEEE 754-2019 โ Floating-Point Arithmetic Standard
- Knuth โ The Art of Computer Programming, Vol. 2
- Unicode Consortium โ Unicode 16.0 Standard
- Computer Organization and Design โ Patterson & Hennessy
- Leibniz โ Explication de l'Arithmรฉtique Binaire (1703)
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)
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.