Binary to Decimal Converter
Convert binary to decimal numbers with step-by-step working. Also shows octal and hex values, plus the conversion formula.
Binary (base 2) is how computers store all data - every file, every number, every instruction is ultimately a sequence of 0s and 1s. This converter provides instant bidirectional conversion between binary and decimal, also showing octal and hexadecimal equivalents. A bit visualisation highlights each bit's positional value, and step-by-step breakdowns explain how the conversion works. All calculations run in your browser with no data sent to any server.
About Binary to Decimal Converter
How Binary to Decimal Conversion Works
Each binary digit (bit) represents a power of 2, starting from 2^0 on the right. Multiply each bit by its positional power and sum all contributions. This positional notation works exactly the same way as decimal - the digit 3 in position 2 of the number 350 means 3 x 100 - except binary only uses two digits instead of ten.
Worked example - convert 11010110 to decimal:
| Bit Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Power of 2 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| Binary: 11010110 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
| Contribution | 128 | 64 | 0 | 16 | 0 | 4 | 2 | 0 |
Sum: 128 + 64 + 16 + 4 + 2 = 214. So binary 11010110 = decimal 214.
The same logic extends to any length. A 16-bit binary number uses positions 0 through 15, where position 15 contributes up to 32,768. A 32-bit number reaches over 4 billion. The tool handles numbers up to JavaScript's BigInt capacity, so there is no practical upper limit.
How Decimal to Binary Conversion Works
The reverse process uses repeated division. Divide the decimal number by 2 and record each remainder. When the quotient reaches 0, read the remainders from bottom to top to get the binary representation.
Worked example - convert 214 to binary:
| Step | Division | Quotient | Remainder |
|---|---|---|---|
| 1 | 214 / 2 | 107 | 0 |
| 2 | 107 / 2 | 53 | 1 |
| 3 | 53 / 2 | 26 | 1 |
| 4 | 26 / 2 | 13 | 0 |
| 5 | 13 / 2 | 6 | 1 |
| 6 | 6 / 2 | 3 | 0 |
| 7 | 3 / 2 | 1 | 1 |
| 8 | 1 / 2 | 0 | 1 |
Reading remainders bottom to top: 11010110. So decimal 214 = binary 11010110. This method works because each division by 2 effectively strips off the least significant bit - the remainder is that bit's value (0 or 1), and the quotient contains the remaining higher bits.
There is also a subtraction method that some find more intuitive: find the largest power of 2 that fits, subtract it, and repeat. For 214: 128 fits (214 - 128 = 86), 64 fits (86 - 64 = 22), 32 does not fit, 16 fits (22 - 16 = 6), 8 does not fit, 4 fits (6 - 4 = 2), 2 fits (2 - 2 = 0), 1 does not fit. Mark each power that fits as 1: 11010110.
Why Computers Use Binary
Transistors - the building blocks of every processor - operate as tiny electronic switches with two stable states: on or off, high voltage or low voltage. Mapping those two states to 1 and 0 gives binary arithmetic for free in hardware. A modern CPU contains billions of transistors. Apple's M4 chip (announced 2024) contains 28 billion transistors built on TSMC's 3nm process. Each transistor switches between states billions of times per second, performing binary logic operations that add up to everything from loading a web page to rendering a video game.
The mathematical foundations go back centuries. Gottfried Wilhelm Leibniz described binary arithmetic in a 1679 manuscript and published his formal treatment in 1703 in the paper "Explication de l'Arithmetique Binaire." But it was Claude Shannon's 1937 MIT master's thesis, "A Symbolic Analysis of Relay and Switching Circuits," that proved Boolean algebra could control electrical relay circuits - effectively showing how binary logic maps onto physical switches. Pioneering computer scientist Herman Goldstine called it "surely one of the most important master's theses ever written."
Common Binary Sizes and Integer Ranges
Computers group bits into fixed-width units. The most common sizes determine what values a variable can hold in programming languages. Picking the right size matters - an 8-bit unsigned integer tops out at 255, which is fine for colour channels but not for counting much else.
| Bit Width | Unsigned Range | Signed Range (Two's Complement) | Common Use |
|---|---|---|---|
| 8 (byte) | 0 to 255 | -128 to 127 | ASCII characters, pixel colour channels, small counters |
| 16 | 0 to 65,535 | -32,768 to 32,767 | Unicode BMP code points, audio samples (CD quality is 16-bit) |
| 32 | 0 to 4,294,967,295 | -2,147,483,648 to 2,147,483,647 | IPv4 addresses, Unix timestamps (until 2038), 32-bit float |
| 64 | 0 to 18,446,744,073,709,551,615 | -9.2 x 10^18 to 9.2 x 10^18 | Memory addresses on modern CPUs, database IDs, 64-bit float |
JavaScript's Number type uses IEEE 754 double-precision (64-bit) floating point, which gives 53 bits of integer precision - that is why Number.MAX_SAFE_INTEGER is 9,007,199,254,740,991 (2^53 - 1). This tool uses BigInt internally, so it can convert numbers far beyond that limit without losing precision.
Powers of 2 Reference
| Power | Value | Significance |
|---|---|---|
| 2^0 | 1 | Least significant bit |
| 2^7 | 128 | Maximum unsigned value of a byte is 255 (2^8 - 1) |
| 2^8 | 256 | Number of values in a byte (0-255) |
| 2^10 | 1,024 | 1 KiB (kibibyte) |
| 2^16 | 65,536 | Max unsigned 16-bit integer + 1 |
| 2^20 | 1,048,576 | 1 MiB (mebibyte) |
| 2^32 | 4,294,967,296 | IPv4 address space (4.3 billion) |
| 2^53 | 9,007,199,254,740,992 | JavaScript Number.MAX_SAFE_INTEGER + 1 |
| 2^64 | 18,446,744,073,709,551,616 | Maximum 64-bit unsigned integer + 1 |
How Do Binary, Octal, and Hex Relate?
Octal (base 8) and hexadecimal (base 16) exist because they map neatly onto binary. Each octal digit represents exactly 3 binary bits, and each hex digit represents exactly 4. That makes them compact shorthand for long binary strings. The number 11111111 in binary is 377 in octal and FF in hex - much easier to read and type. The Hex to Decimal Converter focuses on hex-specific work including colour code lookups.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
The Number Base Converter supports arbitrary bases from 2 to 36 if a base beyond these four is needed.
Where Binary Matters in Practice
Binary is not just an academic concept - it shows up directly in everyday software development and networking tasks.
| Application | How Binary Is Used | Example |
|---|---|---|
| IP addresses | 32-bit binary number split into 4 octets | 192.168.1.1 = 11000000.10101000.00000001.00000001 |
| Subnet masks | Consecutive 1-bits followed by 0-bits | /24 = 11111111.11111111.11111111.00000000 |
| File permissions (Unix) | 3-bit groups for read/write/execute | rwxr-xr-x = 111 101 101 = 755 (octal) |
| Bitwise flags | Each bit represents an on/off option | 0b1010 = features A and C enabled |
| Colour channels | 8 bits per channel (red, green, blue) | Red 255 = 11111111, Blue 0 = 00000000 |
| ASCII encoding | 7 bits per character | 'A' = 1000001 (65 decimal) |
Networking is where binary conversion comes up most often. Calculating whether an IP address falls within a subnet means comparing the binary representations bit by bit - the Subnet Calculator automates that. Unix file permissions (like chmod 755) are really octal shorthand for binary permission bits: read = 4 (100), write = 2 (010), execute = 1 (001). The Chmod Calculator makes that translation visual.
How Do Signed Binary Numbers Work?
Unsigned binary represents only non-negative integers. To handle negative numbers, computers use two's complement - a system where the most significant bit acts as the sign bit. If it is 0, the number is positive. If it is 1, the number is negative.
| Type | Range (8-bit) | Range (16-bit) | Range (32-bit) |
|---|---|---|---|
| Unsigned | 0 to 255 | 0 to 65,535 | 0 to 4,294,967,295 |
| Signed (two's complement) | -128 to 127 | -32,768 to 32,767 | -2,147,483,648 to 2,147,483,647 |
To negate a number in two's complement, flip every bit and add 1. For example, 5 in 8-bit binary is 00000101. Flip all bits to get 11111010, then add 1 to get 11111011 - that is -5. The beauty of two's complement is that addition works the same way for both positive and negative numbers, so the CPU does not need separate circuitry for subtraction. This is why two's complement became the universal standard for signed integers, displacing earlier approaches like sign-magnitude and one's complement that had the awkward problem of representing both +0 and -0.
Common Conversion Mistakes
A few pitfalls come up regularly when working with binary:
Forgetting that positions count from 0. The rightmost bit is position 0 (value 1), not position 1. Getting this wrong shifts every value by a factor of 2.
Reading division remainders in the wrong order. The repeated division method produces remainders from least significant to most significant bit. The first remainder is the rightmost bit, not the leftmost.
Confusing bit count with value count. An 8-bit byte stores 256 values (2^8), but its maximum value is 255 (2^8 - 1) because counting starts at 0.
Ignoring sign representation. The binary string 11111111 means 255 as an unsigned 8-bit integer but -1 as a signed 8-bit integer. Context matters.
Mixing up kilo/kibi prefixes. In computing, 1 KB historically meant 1,024 bytes (2^10), but the IEC standard defines 1 KB as 1,000 bytes and 1 KiB as 1,024 bytes. Storage manufacturers use the SI definition (base 10), while operating systems and memory specs typically use the binary definition (base 2) - which is why a "500 GB" hard drive shows roughly 465 GiB in your file manager.
Assuming leading zeros do not matter. Functionally, 00001010 and 1010 represent the same value (decimal 10). But in contexts like network masks, byte representations, and data formatting, the leading zeros indicate a specific bit width. An 8-bit representation of 10 is 00001010 - dropping the leading zeros can cause issues in protocols that expect fixed-width fields.
Overflow in fixed-width arithmetic. Adding 1 to the 8-bit unsigned value 11111111 (255) produces 100000000 - a 9-bit result. In an 8-bit register, the leading 1 is discarded and the result wraps around to 00000000 (0). This is integer overflow, and it is a common source of bugs in low-level programming. The Year 2038 problem is a well-known example: Unix timestamps stored as signed 32-bit integers will overflow on 19 January 2038, rolling from 2,147,483,647 to -2,147,483,648.
To convert text into its binary representation character by character, the Text to Binary tool handles that directly.
Sources
Frequently Asked Questions
How do you convert binary to decimal?
Each binary digit represents a power of 2 based on its position from right to left, starting at 2^0. Multiply each digit by its corresponding power of 2, then add all the results. For example, binary 1011 equals (1x8) + (0x4) + (1x2) + (1x1) = 11 in decimal.
How do you convert decimal to binary?
Repeatedly divide the decimal number by 2 and record the remainder at each step. Read the remainders from bottom to top to get the binary representation. For example, 13 divided by 2 gives remainders 1, 0, 1, 1 (reading bottom to top), so 13 in binary is 1101.
What is the relationship between binary, octal, and hexadecimal?
All are positional number systems with different bases. Binary is base-2 (digits 0-1), octal is base-8 (digits 0-7), and hexadecimal is base-16 (digits 0-9, A-F). Octal groups binary digits in sets of 3, while hexadecimal groups them in sets of 4, making conversions between these bases straightforward.
What is the largest binary number this tool can handle?
The tool uses JavaScript BigInt internally, so it handles numbers far beyond the standard 2^53 - 1 safe integer limit. You can convert binary strings of hundreds of digits without losing precision. For most practical purposes including programming and networking, even 64-bit numbers (up to about 18.4 quintillion) are well within range.
Related Tools
Link to this tool
Copy this HTML to link to this tool from your website or blog.
<a href="https://toolboxkit.io/tools/binary-to-decimal-converter/" title="Binary to Decimal Converter - Free Online Tool">Try Binary to Decimal Converter on ToolboxKit.io</a>