Binary Calculator
Convert binary, decimal, hex & octal, and do binary math
Last updated October 2026
Method: Conversions use exact positional notation (each digit times its base raised to its place) with arbitrary-precision integers, so values of any length stay exact. Fractions are converted exactly as ratios, and digits that repeat forever are detected and shown in parentheses. Negative integers are also shown in two's complement at the smallest standard width (8, 16, 32 or 64 bits) that fits.
Included: Bidirectional conversion between binary, octal, decimal and hexadecimal, including fractions and negative numbers; addition, subtraction (negative results included), multiplication and integer division of two binary numbers; a place-value breakdown and the result shown in all four bases.
Not included: Floating-point formats such as IEEE 754, bitwise operations (AND, OR, XOR, shifts), fixed-width overflow, and fractions in the Binary math tab (the converter handles them).
๐ Base converter
Type a value in any field and the other three update instantly. Fractions such as 101.101 and a leading minus sign are fine; long values stay exact.
๐ฏ Decimal value
๐ How binary 1010 = 10
| Bit | Place | Contribution |
|---|---|---|
| 1 | 2^3 = 8 | 8 |
| 0 | 2^2 = 4 | 0 |
| 1 | 2^1 = 2 | 2 |
| 0 | 2^0 = 1 | 0 |
| Total | 10 | |
Values of any length are exact (arbitrary-precision integers). Negative numbers are written with a minus sign, and two's complement is shown at the smallest standard width that fits. Division is integer division with a separate remainder.
Binary calculator: convert and compute with base-2 numbers
A binary calculator converts a number between binary (base 2), decimal, hexadecimal and octal and performs binary arithmetic. Binary uses only the digits 0 and 1. For example, binary 1010 equals 10 in decimal, because (1×8) + (0×4) + (1×2) + (0×1) = 10, and the same value is 12 in octal and A in hex. Type any value below, whole number or fraction, to convert or compute instantly.
For hexadecimal arithmetic, the Hex Calculator adds and multiplies in base 16 directly; to read or build signed bit patterns of a chosen width, use the Two's Complement Calculator; and for the remainder of a division on its own, the Modulo Calculator.
What "binary" actually means
A number system's base (or radix) is how many distinct digits it uses. Decimal is base 10 because it uses ten digits, 0 through 9. Binary is base 2: the only legal digits are 0 and 1, called bits (short for "binary digits"). Just as each position in a decimal number is worth ten times the one to its right, each position in a binary number is worth twice the one to its right. So the binary places, reading from the right, are 1, 2, 4, 8, 16, 32, and so on: the powers of two. After a binary point the places continue as halves, quarters and eighths (2−1 = 0.5, 2−2 = 0.25, 2−3 = 0.125), so binary 101.101 is 4 + 1 + 0.5 + 0.125 = 5.625.
Powers of two table: 2ⁿ from 2⁰ to 2¹⁶
Every binary place value is a power of two, so this table is the backbone of all binary math. For example, 2⁸ = 256, a 1 followed by eight zeros, and 2¹⁰ = 1,024, which is why 1,024 bytes are called a kibibyte (KiB); in SI units a kilobyte (kB) is exactly 1,000 bytes.
| Exponent | 2ⁿ (decimal) | Binary | Hex |
|---|---|---|---|
| 2⁰ | 1 | 1 | 1 |
| 2¹ | 2 | 10 | 2 |
| 2² | 4 | 100 | 4 |
| 2³ | 8 | 1000 | 8 |
| 2⁴ | 16 | 10000 | 10 |
| 2⁵ | 32 | 100000 | 20 |
| 2⁶ | 64 | 1000000 | 40 |
| 2⁷ | 128 | 10000000 | 80 |
| 2⁸ | 256 | 100000000 | 100 |
| 2⁹ | 512 | 1000000000 | 200 |
| 2¹⁰ | 1,024 | 10000000000 | 400 |
| 2¹² | 4,096 | 1000000000000 | 1000 |
| 2¹⁴ | 16,384 | 100000000000000 | 4000 |
| 2¹⁶ | 65,536 | 10000000000000000 | 10000 |
The conversion formula
To read any number in any base, multiply each digit by its place value and add. Formally, a number with digits d in base b has the value:
value = dₙ × bⁿ + … + d₂ × b² + d₁ × b¹ + d₀ × b⁰ For binary, b = 2. So the binary number 1011 equals (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11. The calculator above prints exactly this breakdown, bit by bit, so the answer is never a black box.
Worked example: binary to decimal
Take the byte 11001010. Line up the place values 128, 64, 32, 16, 8, 4, 2, 1 under the bits. Wherever there is a 1, add that place value: 128 + 64 + 8 + 2 = 202. Wherever there is a 0, add nothing. That is the entire trick to reading binary: it is just addition of selected powers of two.
What is 128 + 64 + 32 + 16 + 8 in binary?
Adding a run of powers of two sets one bit each. The sum 128 + 64 + 32 + 16 + 8 = 248, which is 11111000 in binary (hex F8, octal 370). The step-by-step breakdown below shows each place value and whether its bit is on.
| Place value | 2ⁿ | Bit | Adds |
|---|---|---|---|
| 128 | 2⁷ | 1 | 128 |
| 64 | 2⁶ | 1 | 64 |
| 32 | 2⁵ | 1 | 32 |
| 16 | 2⁴ | 1 | 16 |
| 8 | 2³ | 1 | 8 |
| 4 | 2² | 0 | 0 |
| 2 | 2¹ | 0 | 0 |
| 1 | 2⁰ | 0 | 0 |
| Total | 11111000 | 248 |
Worked example: decimal to binary
Going the other way, use repeated division by 2 and collect the remainders. Convert 156: 156 / 2 = 78 r 0, 78 / 2 = 39 r 0, 39 / 2 = 19 r 1, 19 / 2 = 9 r 1, 9 / 2 = 4 r 1, 4 / 2 = 2 r 0, 2 / 2 = 1 r 0, 1 / 2 = 0 r 1. Read the remainders from bottom to top: 10011100. Typing 156 in the decimal field returns the same result without the longhand.
Worked example: binary addition
Binary addition uses the same columns as decimal, but you carry as soon as a column reaches 2 instead of 10. The four rules are 0+0=0, 0+1=1, 1+0=1, and 1+1=0 with a carry of 1. Add 1010 (10) and 110 (6): the rightmost columns produce carries that ripple left, and the answer is 10000, which is 16, exactly 10 + 6. The Binary math tab shows both the binary and decimal forms so you can check yourself.
How to use this calculator
- Pick a mode at the top: "Convert" to translate one number across bases, or "Binary math" to add, subtract, multiply or divide.
- To convert, type into any of the four fields: binary, octal, decimal or hexadecimal. The other three update the instant you type, so you can start from whichever base you know. Fractions (101.101 or 0.1), a minus sign, prefixes such as 0x or 0b, and spaces between bit groups are all fine.
- Read the result. The big number shows the decimal value, the cards show all four bases (repeating digits in parentheses), and the table breaks the binary number into its place values. A negative number also gets its two's complement bit pattern.
- To do math, switch to Binary math, enter two binary numbers (only 0s and 1s), tap an operator, and read the result in binary plus its decimal, octal and hex equivalents. A negative difference is shown with a minus sign and in two's complement.
- Watch for errors. If you type a digit that is illegal for the chosen base (say an
8in a binary field), the calculator flags it instead of guessing.
Who this tool is for
- Students learning number systems in a computer-science, electronics or math class who need to check homework and see the steps.
- Programmers reading hex color codes, bitmasks, memory addresses, or file permissions and wanting a fast cross-base translation.
- Hardware and networking folks working with registers, subnet masks, and IP addresses, where binary and hex are everywhere.
- Anyone curious who has wondered what "01000001 is the letter A" really means and wants to play with the math directly.
Key terms explained
- Bit: a single binary digit, either 0 or 1. The smallest unit of data.
- Byte: a group of 8 bits. A byte holds 2⁸ = 256 patterns, the values 0 to 255.
- Nibble: 4 bits, exactly one hexadecimal digit. Two nibbles make a byte.
- Base / radix: the number of digits a system uses: 2 for binary, 8 for octal, 10 for decimal, 16 for hex.
- Most/least significant bit (MSB/LSB): the leftmost bit carries the largest place value; the rightmost carries the smallest (the ones place).
- Place value: the worth of a digit based on its position, a power of the base.
- Two's complement: the usual way computers store negative integers in a fixed number of bits; the width must always be stated, because −10 is 11110110 in 8 bits but 1111111111110110 in 16 bits.
Quick reference: common conversions
The table below lists frequently used values across all four bases. Each binary entry is padded to a tidy width so the bit patterns line up.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 4 | 0100 | 4 | 4 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 32 | 100000 | 40 | 20 |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 128 | 10000000 | 200 | 80 |
| 255 | 11111111 | 377 | FF |
Why hex and octal are binary shorthand
Long bit strings are hard to read, so programmers compress them. Because 16 = 2⁴, every hexadecimal digit maps to exactly four bits: 1111 is F, 1010 is A, and so on. The byte 11001010 splits into 1100 and 1010, which is CA in hex. Similarly, because 8 = 2³, each octal digit stands for three bits. That tight mapping is why color codes (#FF8800), memory addresses, and Unix file permissions (chmod 755) are written in hex or octal rather than raw binary.
Binary subtraction, multiplication and division
Subtraction works column by column with borrowing, mirroring decimal: 1010 − 110 = 100 (10 − 6 = 4). When the second number is larger, the result is negative: 110 − 1010 = −100 (−4), which the calculator also shows as 11111100 in 8-bit two's complement. Multiplication is a series of shifts and adds; multiplying by a power of two just appends zeros, so 101 × 10 = 1010 (5 × 2 = 10). Division is integer division: 1011 / 10 = 101 remainder 1 (11 / 2 = 5 r 1). The tool always shows the remainder separately so nothing is silently dropped.
Binary math examples: add, subtract, multiply, divide
This matrix runs every operation on the same pairs of binary numbers so you can check the pattern. Each cell is the result in binary with its decimal value in parentheses; division shows quotient and remainder.
| A | B | A + B | A − B | A × B | A ÷ B |
|---|---|---|---|---|---|
| 1010 (10) | 110 (6) | 10000 (16) | 100 (4) | 111100 (60) | 1 r 100 (1 r 4) |
| 1100 (12) | 101 (5) | 10001 (17) | 111 (7) | 111100 (60) | 10 r 10 (2 r 2) |
| 1111 (15) | 11 (3) | 10010 (18) | 1100 (12) | 101101 (45) | 101 r 0 (5 r 0) |
| 10101 (21) | 1101 (13) | 100010 (34) | 1000 (8) | 100010001 (273) | 1 r 1000 (1 r 8) |
| 11001010 (202) | 1111 (15) | 11011001 (217) | 10111011 (187) | 101111010110 (3030) | 1101 r 111 (13 r 7) |
Tips for working in binary
- Memorize the powers of two (1, 2, 4, 8, 16, 32, 64, 128, 256...). Almost all binary mental math leans on them.
- Group bits in fours from the right when reading long numbers; it lines them up with hex and is far easier to scan.
- A leading zero never changes the value: 0101 and 101 are both 5. Padding is just for alignment.
- Doubling = a left shift. Appending a 0 on the right multiplies by 2, just as adding a 0 to a decimal number multiplies by 10.
Common pitfalls
The mistakes below trip up almost everyone learning binary; the calculator is built to catch them.
- Using illegal digits: a 2 in binary or an 8 in octal is invalid. The tool flags these instead of producing a wrong answer.
- Reading bits in the wrong direction: the rightmost bit is the ones place, not the leftmost.
- Forgetting the carry in addition when a column hits 1+1.
- Mixing up octal and hex: both compress binary, but in groups of three versus four bits.
- Expecting every decimal fraction to end in binary: only fractions whose denominator is a power of 2 do; 0.1 becomes 0.0(0011), repeating forever.
Binary in computing: text, color and permissions
Once a value is a string of bits, the same bits can mean very different things depending on how software interprets them. Text uses character encodings: in ASCII the letter A is the number 65, which is 01000001 in binary and 41 in hex; lowercase a is 97 (01100001). Color on the web is three bytes, one each for red, green and blue, so the hex code #FF8800 means red 255, green 136, blue 0, and each channel runs from 0 to 255 precisely because a byte holds 256 values. Unix file permissions use three octal digits, where each digit is three permission bits (read = 4, write = 2, execute = 1); chmod 755 grants the owner read+write+execute (7) and everyone else read+execute (5). Reading these everyday codes is just base conversion, which is exactly what the calculator above does.
Binary mental math: shortcuts worth learning
You can do a surprising amount of binary work in your head once a few shortcuts stick. Powers of two double each step (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024), and 2¹⁰ = 1,024 is why memory is counted in kibibytes of 1,024 bytes rather than SI kilobytes of 1,000. One less than a power of two is all ones: 2⁴ is 16, so 15 is 1111; 2⁸ is 256, so 255 is 11111111. That pattern is why the largest unsigned value in n bits is always 2ⁿ − 1. To halve, shift right; dropping the rightmost bit divides by two and the dropped bit is the remainder, so an odd number simply ends in 1. These tricks turn most conversions into recognition rather than long division.
Limitations and assumptions
This calculator is a learning and conversion aid, not a full bit-manipulation environment. Keep these boundaries in mind:
- Negative numbers are written with a minus sign in every base; two's complement is shown separately at the smallest standard width that fits, not as a fixed-width register that can overflow.
- Fraction digits that never end are cut off in the fields (32 binary, 12 octal, 10 hex and 40 decimal places), with the repeating block shown in the result card. Floating-point formats such as IEEE 754 are not modeled.
- The Binary math tab takes non-negative whole numbers; a subtraction may still return a negative result.
- Division is integer division with a separate remainder, not exact decimal division.
- Values of any length are exact; only the place-value table is limited to 64 binary digits.
Related concepts and calculators
Binary is one corner of a larger toolkit for working with numbers. To raise a number to a power, which is exactly what computing place values does, use the Exponent Calculator. The Scientific Calculator handles logarithms (log base 2 tells you how many bits a value needs) and more advanced functions. For base-16 arithmetic the Hex Calculator is the dedicated tool, for signed bit patterns the Two's Complement Calculator, and for integers too long for an ordinary calculator the Big Number Calculator. Together they cover most of the number-base math you meet beyond a simple four-function calculator.
Sources
- National Institute of Standards and Technology, Prefixes for binary multiples: kibi (Ki) = 210 = 1,024 and mebi (Mi) = 220, approved by the International Electrotechnical Commission in December 1998, while the SI prefix kilo (k) means 1,000.
- ECMAScript Language Specification, §6.1.6.2 The BigInt Type: integers of any size, with bitwise operations defined on two's complement binary strings. This is the exact integer arithmetic the calculator uses.
โ ๏ธ Common mistakes & edge cases
Typing a digit that the base does not allow
Binary only has 0 and 1; octal stops at 7; hex runs from 0 to 9 and then A to F. A "2" in a binary field or a "G" in a hex field is meaningless. The calculator rejects illegal digits and tells you which base they break, rather than quietly returning the wrong number.
Reading the bits backwards
The least significant bit is on the right (the ones place), and value grows to the left. Reading 110 as 6, not 3, depends on getting this direction right. The place-value table makes the order explicit.
Forgetting the width in two's complement
A negative number has no single binary pattern until you fix the number of bits: −10 is 11110110 in 8-bit two's complement and 1111111111110110 in 16-bit. The converter writes negatives with a minus sign and states the width whenever it shows a two's complement pattern.
Confusing integer division with exact division
Binary division here returns a whole-number quotient plus a remainder, like long division. So 1011 / 10 is 101 remainder 1, not 101.1. Read both the quotient and the remainder to get the full picture.
❓ Frequently asked questions
How do you convert binary to decimal?
Multiply each binary digit by its place value, which is a power of 2, and add the results. Reading right to left, the places are 1, 2, 4, 8, 16, and so on. For example, 1011 = (1 ร 8) + (0 ร 4) + (1 ร 2) + (1 ร 1) = 8 + 0 + 2 + 1 = 11. The converter above shows this place-value breakdown for any number you type.
How do you convert decimal to binary?
Repeatedly divide the decimal number by 2 and record each remainder. The remainders, read from the last one to the first, are the binary digits. For example, 13 divided by 2 is 6 remainder 1, 6 divided by 2 is 3 remainder 0, 3 divided by 2 is 1 remainder 1, and 1 divided by 2 is 0 remainder 1, giving 1101. Just type 13 in the decimal field and the binary appears instantly.
What is binary used for?
Binary (base 2) is how computers store and process all data, because a circuit is naturally either off (0) or on (1). Numbers, text, images, and instructions are ultimately sequences of bits. Programmers also use hexadecimal (base 16) and octal (base 8) as shorthand for binary because each hex digit maps to exactly four bits and each octal digit to three.
How does binary addition work?
Binary addition follows the same column method as decimal, but it carries whenever a column reaches 2. The rules are 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, and 1 + 1 = 10 (write 0, carry 1). For example, 1010 + 110 = 10000 in binary, which is 10 + 6 = 16 in decimal. The Binary math tab does this for you and also shows the decimal equivalent.
Can this calculator subtract, multiply and divide binary numbers?
Yes. Switch to the Binary math tab, enter two binary numbers, and choose +, โ, ร or รท. If the second number is larger, the difference is negative: it is written with a minus sign and also shown in two's complement at the smallest standard width that fits (for example 110 โ 1010 = โ100, which is 11111100 in 8-bit two's complement). Division is integer division: it returns a whole-number quotient plus a separate remainder, both shown in binary and decimal.
What is the difference between binary, octal, decimal and hexadecimal?
They are number systems with different bases: binary is base 2 (digits 0 and 1), octal is base 8 (digits 0 to 7), decimal is base 10 (digits 0 to 9), and hexadecimal is base 16 (digits 0 to 9, then A to F). The same quantity looks different in each base. For example, decimal 255 is 11111111 in binary, 377 in octal, and FF in hexadecimal.
Why does hexadecimal use the letters A to F?
Hexadecimal has sixteen digits, but we only have ten numeral symbols (0 to 9). The letters A, B, C, D, E, and F stand in for the values 10, 11, 12, 13, 14, and 15. So hex FF means 15 ร 16 + 15 = 255. Hex is popular with programmers because one hex digit represents exactly four binary digits, making long bit patterns easy to read.
How many values can a byte represent?
A byte is 8 bits. Each bit can be 0 or 1, so a byte has 2^8 = 256 possible patterns, representing the values 0 through 255 when it is read as an unsigned number (or โ128 through 127 in 8-bit two's complement). That is why color channels, for instance, often run from 0 to 255. More generally, n bits can represent 2^n different values.
Does this binary calculator handle negative numbers or fractions?
Yes, in the converter. Type a fraction such as 101.101 (binary) or 5.625 (decimal) and every base updates exactly; when a decimal fraction has no finite binary form, the repeating digits are shown in parentheses. Type a minus sign for a negative number: the fields write the sign in front, and a separate card shows the two's complement bit pattern with its width (for example โ10 is 11110110 in 8 bits). The Binary math tab works with whole numbers, and its subtraction may return a negative result.
What is 0.1 in binary?
0.1 has no exact binary form. Multiply by 2 repeatedly and keep the whole-number parts: 0.2 gives 0, 0.4 gives 0, 0.8 gives 0, 1.6 gives 1, 1.2 gives 1, and then the pattern starts over, so 0.1 = 0.0001100110011โฆ in binary, written 0.0(0011) with the repeating block in parentheses. Fractions with a denominator that is a power of 2, such as 0.5 = 0.1 or 0.625 = 0.101, end; most other decimals repeat, which is why computers store 0.1 only approximately.
What is the largest number this calculator can handle?
There is no fixed limit. Conversions and arithmetic use arbitrary-precision integers (BigInt), so a 100-bit binary number or a 40-digit decimal number converts exactly, digit for digit. Only the place-value table is limited to values of up to 64 binary digits, and fraction digits that never end are cut off after a set number of places (32 in binary, for example).
How do I convert binary to hexadecimal by hand?
Group the bits into fours starting from the right, padding the leftmost group with zeros if needed, then convert each group of four bits to a single hex digit (0000 = 0 up to 1111 = F). For example, 11001010 splits into 1100 and 1010, which are C and A, giving CA. This works because 16 = 2^4, so one hex digit always equals exactly four bits. The converter does this instantly when you type a binary number.
Why is one kilobyte 1024 bytes instead of 1000?
Strictly speaking it is not: kilo is the SI prefix for 1,000, so a kilobyte (kB) is 1,000 bytes. The confusion comes from computer memory, which is addressed in powers of two, and 2^10 = 1,024 is the power of two closest to 1,000, so 1,024 bytes was long called a kilobyte too. To remove the ambiguity, the International Electrotechnical Commission approved binary prefixes in December 1998: 1 kibibyte (KiB) = 1,024 bytes and 1 mebibyte (MiB) = 1,048,576 bytes, as NIST explains.
Is binary the same as a QR code or barcode?
Not exactly, though they are related. Binary is the underlying number system of 0s and 1s. A barcode or QR code is a visual encoding that ultimately stores binary data, with dark and light modules standing in for 1s and 0s, plus error-correction bits. So binary is the language; the code is one physical way of writing it down. This calculator works with the binary numbers themselves, not the printed symbols.
What is 2 to the power of 8 (2^8)?
2^8 = 256. In binary it is written 100000000, a 1 followed by eight zeros, and 100 in hexadecimal. This value matters because 8 bits make one byte, and n bits can represent 2^n patterns, so a byte holds 256 distinct values, the numbers 0 through 255. Enter 256 in the decimal field to confirm the binary form.
What is 110 in binary equal to in decimal?
The binary number 110 equals 6 in decimal, not 110. Read the place values right to left: (1 ร 4) + (1 ร 2) + (0 ร 1) = 4 + 2 + 0 = 6. Do not confuse the binary string 110 with the decimal number 110, which is 1101110 in binary. Type the value into the matching field above to convert either way.
๐ก Good to know
Every hex digit is exactly four bits
Because 16 = 2⁴, you can convert between binary and hexadecimal by splitting the bits into groups of four from the right. That is why programmers lean on hex: it is binary, just four times shorter and far easier to read.
Leading zeros are free
0000 1010 and 1010 are the same number (10). Padding to 4 or 8 bits only helps readability and alignment with bytes; it never changes the value of an unsigned number.
n bits hold 2 to the n values
One bit gives 2 options, a nibble (4 bits) gives 16, and a byte (8 bits) gives 256 (0 to 255). Doubling the bit count squares the range, which is why even small bit-widths cover huge numbers.
Related Calculators
Hex Calculator
Add, subtract, multiply and convert hexadecimal numbers
Two's Complement Calculator
Convert between decimal and two's complement binary
Modulo Calculator
Remainder of a division (a mod n)
Big Number Calculator
Exact arithmetic on very large numbers
Exponent Calculator
Raise numbers to any power
Logarithm Calculator
Calculate log and natural log of any number
Scientific Notation Calculator
Convert numbers to and from scientific notation
Scientific Calculator
A full scientific calculator with trig, logs and more