Binary Calculator — Free Online Binary Converter and Arithmetic
Convert between binary and decimal numbers and perform binary arithmetic operations including addition, subtraction, multiplication, and division.
Conversion Results
Decimal to Binary
42 = 101010
Binary to Decimal
101010 = 42
Binary to Hexadecimal
101010 = 0x2A
How to Use the Binary Calculator
- Select the operation: Use the dropdown to choose between number conversion and four arithmetic operations. The conversion mode handles binary-to-decimal and decimal-to-binary simultaneously.
- For conversions: Enter a decimal number in the first field and the calculator shows its binary equivalent. Enter a binary number (using only 0s and 1s) in the second field to see its decimal and hexadecimal equivalents. Both fields work independently.
- For arithmetic: Enter two binary numbers in the provided fields. The calculator shows each value's decimal equivalent below the input for convenience. The result appears in both binary and decimal formats.
- Read the binary result: The main result is shown in binary. For arithmetic operations, the full equation is displayed in both binary and decimal notation, making it easy to verify the calculation.
- Check hexadecimal equivalents: In conversion mode, the hexadecimal representation is also shown, as hex is commonly used alongside binary in programming.
All results update in real time. Binary inputs are validated — only 0s and 1s are accepted. For division, the calculator shows both the quotient and remainder.
Binary Conversion Formulas
Binary to Decimal
D = b(n) x 2^n + b(n-1) x 2^(n-1) + ... + b(1) x 2 + b(0) x 1 Decimal to Binary
Repeatedly divide by 2, read remainders bottom-to-top Binary Addition Rules
0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry 1) Variables Explained
- b(n), b(n-1), ..., b(0): The individual binary digits (bits), where b(0) is the rightmost (least significant) bit and b(n) is the leftmost (most significant) bit.
- 2^n: The positional weight of each bit. From right to left: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, and so on (powers of 2).
- D: The decimal (base-10) equivalent of the binary number.
Step-by-Step Example
Convert binary 10110101 to decimal:
- Write the positional values: 128, 64, 32, 16, 8, 4, 2, 1
- Multiply each by the corresponding bit: 1x128 + 0x64 + 1x32 + 1x16 + 0x8 + 1x4 + 0x2 + 1x1
- Sum: 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181
Binary 10110101 = decimal 181. To convert back: 181/2=90 R1, 90/2=45 R0, 45/2=22 R1, 22/2=11 R0, 11/2=5 R1, 5/2=2 R1, 2/2=1 R0, 1/2=0 R1. Reading remainders bottom-to-top: 10110101, confirming the conversion.
Practical Examples
Example 1: Jake's Networking Assignment
Jake is studying IP addressing and needs to convert the subnet mask 255.255.255.0 to binary to understand network segmentation.
- 255 in binary: 11111111 (8 bits, all ones)
- 0 in binary: 00000000 (8 bits, all zeros)
- Subnet mask: 11111111.11111111.11111111.00000000
- This is a /24 network: 24 ones followed by 8 zeros
Jake can now see that the subnet mask has 24 network bits and 8 host bits, allowing 254 usable host addresses (2^8 - 2). Understanding binary is essential for network engineering, where IP addresses, subnet masks, and routing decisions all operate at the binary level.
Example 2: Maria's Computer Architecture Class
Maria needs to add two 8-bit binary numbers for her computer architecture homework: 01101011 + 10010110.
- 01101011 = 107 in decimal
- 10010110 = 150 in decimal
- Binary addition: 01101011 + 10010110 = 100000001 (9 bits)
- Decimal verification: 107 + 150 = 257
The result is 100000001 (257 in decimal). Note that the sum requires 9 bits, exceeding the 8-bit width. In a real computer with 8-bit registers, this would cause an overflow, wrapping around to 00000001 (1) with a carry flag set. Understanding binary overflow is critical for programming and systems engineering.
Example 3: Tyler's Color Code Conversion
Tyler is a web developer working with CSS colors. He needs to convert the RGB color value (200, 100, 50) to binary for a low-level graphics library.
- Red: 200 = 11001000
- Green: 100 = 01100100
- Blue: 50 = 00110010
- 24-bit color: 11001000 01100100 00110010
Each color channel is an 8-bit value (0-255), and together they form a 24-bit color. In hexadecimal, this color is #C86432, which is much more readable than the binary representation. This is why web developers use hex color codes — each pair of hex digits represents one 8-bit color channel. For hex conversions, use our hex calculator.
Binary-Decimal Conversion Reference
| Decimal | Binary | Hex | Bits |
|---|---|---|---|
| 1 | 1 | 1 | 1 |
| 10 | 1010 | A | 4 |
| 42 | 101010 | 2A | 6 |
| 100 | 1100100 | 64 | 7 |
| 255 | 11111111 | FF | 8 |
| 1000 | 1111101000 | 3E8 | 10 |
| 65535 | 1111111111111111 | FFFF | 16 |
Tips and Complete Guide
Powers of 2 — The Foundation
Memorizing the first several powers of 2 makes binary work much faster: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096. These correspond to the value of each bit position from right to left. Converting binary to decimal becomes instant mental math when you recognize these values. The number 1024 (2^10) is particularly important — it is roughly 1000, which is why computer storage uses "kilo" to mean 1024 rather than 1000 (though the SI standard now uses "kibi" for 1024).
Binary in Digital Electronics
Binary is the native language of all digital systems. Transistors — the building blocks of processors — operate as switches that are either on (1) or off (0). Logic gates (AND, OR, NOT, XOR) perform binary operations on individual bits. An 8-bit processor can handle values 0-255 in one operation, a 32-bit processor handles values up to about 4.3 billion, and a 64-bit processor handles values up to about 18.4 quintillion. Understanding binary is essential for anyone working in hardware design, embedded systems, or low-level programming.
Bitwise Operations in Programming
Programmers use bitwise operations for performance-critical code. AND (&) masks specific bits, OR (|) sets bits, XOR (^) toggles bits, and bit shifts (<<, >>) multiply or divide by powers of 2 much faster than regular multiplication. These operations are used in graphics programming, network protocols, encryption, and system programming. For example, checking if a number is odd in binary requires only checking the last bit: n & 1.
Binary and Data Storage
All digital data — text, images, audio, video — is ultimately stored as binary. ASCII text uses 7-8 bits per character (A = 01000001). Unicode extends this to handle all world scripts. Images store each pixel's color as binary values (24 bits for RGB). Compression algorithms like ZIP and MP3 reduce the number of binary digits needed to represent data. Understanding binary helps you grasp storage capacity, data transfer rates, and compression ratios at a fundamental level.
Common Mistakes to Avoid
- Using digits other than 0 and 1: Binary numbers contain only 0s and 1s. Including any other digit makes the number invalid in base-2. Our calculator validates input to prevent this error.
- Forgetting leading zeros in fixed-width representations: In computing, 5 as an 8-bit binary is 00000101, not just 101. Leading zeros matter when working with fixed-width data formats.
- Misreading bit positions: The rightmost bit is position 0 (value 1), not position 1. Numbering starts from the right (least significant bit) and increases leftward.
- Overflow in binary arithmetic: Adding two n-bit numbers can produce an (n+1)-bit result. In fixed-width systems, the extra bit is lost, causing incorrect results. Always check if your result fits the available bit width.
- Confusing binary 10 with decimal 10: Binary 10 equals decimal 2, not 10. Always specify the base when writing numbers to avoid ambiguity. Use prefixes like 0b (binary) or subscripts where possible.
Frequently Asked Questions
The binary number system (base-2) uses only two digits: 0 and 1. Each position represents a power of 2, just as each position in decimal represents a power of 10. For example, binary 1011 = 1x2^3 + 0x2^2 + 1x2^1 + 1x2^0 = 8 + 0 + 2 + 1 = 11 in decimal. Binary is the foundation of all digital computing because electronic circuits can reliably distinguish between two states (on/off, high/low voltage).
To convert a decimal number to binary, repeatedly divide by 2 and record the remainders from bottom to top. For example, converting 42: 42/2=21 R0, 21/2=10 R1, 10/2=5 R0, 5/2=2 R1, 2/2=1 R0, 1/2=0 R1. Reading remainders bottom-to-top: 101010. So decimal 42 = binary 101010. You can verify: 32+8+2 = 42. Our calculator performs this conversion instantly in both directions.
To convert binary to decimal, multiply each digit by its positional power of 2 and sum the results. For binary 110101: starting from the right, 1x1 + 0x2 + 1x4 + 0x8 + 1x16 + 1x32 = 1 + 0 + 4 + 0 + 16 + 32 = 53. The rightmost digit is the ones place (2^0), the next is twos (2^1), then fours (2^2), and so on. Each position doubles the value of the one to its right.
Binary addition follows the same column-by-column principle as decimal addition, but with simpler rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 carry 1), 1+1+1=11 (1 carry 1). For example, 1011 + 1101: rightmost column 1+1=10 (write 0 carry 1), next 1+0+1=10 (write 0 carry 1), next 0+1+1=10 (write 0 carry 1), next 1+1+1=11 (write 1 carry 1), carry gives final 1. Result: 11000 (= 24 in decimal, verifiable as 11+13=24).
Binary subtraction uses borrowing, similar to decimal subtraction. The rules are: 0-0=0, 1-0=1, 1-1=0, 0-1 requires borrowing (borrow 1 from the next column, making it 10-1=1). For example, 1101 - 1010: rightmost 1-0=1, next 0-1 borrows to get 10-1=1, next 0-0=0 (was 1 but we borrowed), next 1-1=0. Result: 0011 = 3, verified as 13-10=3.
A bit is a single binary digit (0 or 1) — the smallest unit of data. A nibble is 4 bits (representing values 0-15, or one hexadecimal digit). A byte is 8 bits (representing values 0-255). These groupings are fundamental in computing: memory is addressed in bytes, file sizes are measured in bytes (KB, MB, GB), and network speeds are measured in bits per second. Use our <a href='/math/number-systems/hex-calculator' class='text-primary-600 hover:text-primary-800 underline'>hex calculator</a> for hexadecimal conversions.
Computers typically use two's complement to represent negative numbers. To negate a binary number: (1) flip all bits (0 becomes 1, 1 becomes 0), (2) add 1. For example, -5 in 8-bit two's complement: 5 = 00000101, flip to 11111010, add 1 to get 11111011. The most significant bit acts as a sign bit (0 = positive, 1 = negative). Our calculator shows the simple signed representation with a minus sign for clarity.
Hexadecimal (base-16) provides a compact way to represent binary numbers. Each hex digit corresponds to exactly 4 binary digits (a nibble). For example, binary 11010110 = D6 in hex (1101=D, 0110=6). This 4:1 mapping makes hex much easier to read than long binary strings while maintaining a direct mathematical relationship. Programmers routinely use hex as shorthand for binary values in memory addresses, color codes (like #FF0000), and machine code.
Related Calculators
Hex Calculator
Convert and perform arithmetic with hexadecimal numbers. Hex to decimal, binary, and more.
GCF Calculator
Find the Greatest Common Factor of two or more numbers using the Euclidean algorithm.
Number Sequence Calculator
Analyze arithmetic, geometric, and Fibonacci sequences with pattern detection.
Scientific Calculator
Advanced calculations with trigonometry, logarithms, and scientific functions.
Percentage Calculator
Calculate percentages, percentage change, and more with five operation modes.
Grade Calculator
Calculate weighted grades and GPA across multiple assignments and courses.
Disclaimer: This calculator is for informational and educational purposes only. Results are estimates and may not reflect exact values.
Last updated: February 23, 2026
Sources
- Khan Academy — Number Systems: khanacademy.org
- Math is Fun — Binary Number System: mathsisfun.com
- Purplemath — Number Bases: purplemath.com