Solved.tools โ€” Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Binary to Decimal Converter

Last updated: 15 August 2026

Reviewed by Gavin ยท Research and drafting assisted by AI

Was this helpful?


Convert any number between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). This tool uses arbitrary-precision integer arithmetic, so even very long binary strings (hundreds of bits) convert exactly, no floating-point rounding errors.

Binary, octal, decimal, and hexadecimal are all positional number systems that express the same set of integers in different notations. A positional system uses a fixed base and a digit set whose size matches the base; the value of each digit is multiplied by the base raised to the position's power. Once you understand that, conversion between any two bases is mechanical, and the four systems covered here are the most common ones in computing, with binary underlying everything digital and decimal being the human default.

This converter is designed for clarity and exactness. It uses JavaScript's BigInt type, which has no fixed upper bound on integer size and so handles inputs of essentially any length without losing precision. Floating-point conversion issues that plague naive implementations (Number is a double-precision IEEE 754 float, which only has about 15 to 17 decimal digits of precision) do not apply here. You can paste a 500-bit binary string and get the exact decimal, octal, and hex equivalents.

How to Use This Tool

  1. Type or paste a number into the input field.
  2. Pick the input base (binary, octal, decimal, or hex).
  3. Click Calculate.
  4. Read the equivalent values in all four bases, plus the bit-length of the binary representation.

Once converted, the result shows all four representations at once. The bit-length field is useful when you want to know how many bits a given value occupies, handy for bit-width planning (is this value going to fit in a 16-bit unsigned integer?) and for understanding two's complement representations. The decimal output is monotonically formatted with thousands separators for readability, but the underlying value is unaffected.

How the Conversion Works

Every integer has a unique representation in each base. The standard algorithm for converting between bases is repeated division by the target base (toBase) or repeated multiplication by the source base (fromBase). For bases that are powers of two (binary = 2, octal = 8 = 2ยณ, hex = 16 = 2โด), a shortcut exists: group the binary digits into chunks of the appropriate size and read each chunk.

Binary โ†’ Hex (group by 4): 1010 1100 โ†’ A C โ†’ 0xAC.

Binary โ†’ Octal (group by 3): 101 011 100 โ†’ 5 3 4 โ†’ 534โ‚ˆ.

Hex โ†’ Binary (each digit โ†’ 4 bits): 0xAC โ†’ 1010 1100.

The grouping shortcut is exact because each new base is a power of two. So binary โ†’ hex converts in O(n) time with constant work per group, and the same applies for binary โ†’ octal. When converting to binary from any base, you reverse the process: expand each digit into the appropriate number of bits and concatenate.

For pairs that don't share a base relationship (e.g., decimal โ†’ binary or hexadecimal โ†’ decimal), the algorithm is divide-and-remainder. To convert N to base b, repeatedly divide N by b and record the remainder; the remainders read bottom-up are the digits in the new base. This is what the toBase helper in this tool does, generalized to BigInt to avoid overflow.

Worked Examples

Binary 1010 โ†’ decimal 10: 1ร—2ยณ + 0ร—2ยฒ + 1ร—2ยน + 0ร—2โฐ = 8 + 0 + 2 + 0 = 10.

Hex 0xDEADBEEF โ†’ decimal 3735928559: 13ร—16โท + 14ร—16โถ + 10ร—16โต + 13ร—16โด + 11ร—16ยณ + 14ร—16ยฒ + 14ร—16ยน + 15ร—16โฐ = 3735928559.

Decimal 255 โ†’ hex 0xFF: 255 รท 16 = 15 remainder 15 (F); 15 รท 16 = 0 remainder 15 (F). So 0xFF.

Decimal 1000 โ†’ binary 1111101000: 1000 in binary has 10 bits and equals 0x3E8.

Octal 0755 โ†’ decimal 493: Unix file permissions. 7ร—8ยฒ + 5ร—8ยน + 5ร—8โฐ = 448 + 40 + 5 = 493.

IPv4 192.168.1.1 โ†’ hex 0xC0A80101: Split into octets (192, 168, 1, 1), convert each to hex (C0, A8, 01, 01), and concatenate. As a 32-bit integer it is 3232235777 in decimal.

RGB (#FF8800) โ†’ 24-bit integer 16744448: Each hex pair is one byte. 0xFF = 255, 0x88 = 136, 0x00 = 0. Concatenating the bytes gives 0xFF8800 = 16,744,448.

SHA-256 fragment 0xA3F9 โ†’ decimal 41977: 10ร—16ยณ + 3ร—16ยฒ + 15ร—16ยน + 9ร—16โฐ = 16384 + 768 + 240 + 9 = 17401. (A = 10, F = 15.)

Where It Shows Up

  • Programming, bit manipulation, bitmasks, flag combinations (e.g. Unix file permissions in octal 0755).
  • Networking, IPv4 addresses in dotted-decimal (192.168.1.1) and their underlying 32-bit values.
  • Colour codes, web colours in hex (#FF8800), RGB triples, and the underlying 24-bit value.
  • Memory and storage, addressing in hex, bit widths in computer architecture.
  • Crypto and hashing, hex representations of SHA-1, SHA-256, MD5, and other hash outputs.
  • Embedded systems, bitwidth registers, mask-and-set operations, hardware configuration words.
  • Assembly language, machine code disassembled to hex is grouped 2 or 4 bytes per instruction.
  • CTF and forensics, magic bytes, PE headers, and exploit payloads are routinely inspected in hex.

Common Mistakes

  • Confusing signed and unsigned integers. Binary representation of -1 in two's complement is 0xFFFFFFFF (32-bit) or all-ones of any width, but the converter treats all inputs as non-negative.
  • Confusing hex notation 0x10 (16) with decimal 10. 0x10 = 16, not 10.
  • Octal leading-zero confusion. In some languages (C, Python 2, Perl), a literal with a leading zero is octal: 0755 = 493 decimal, not 755.
  • Bit-grouping mistakes. When converting binary to hex, pad the binary on the LEFT with zeros to a multiple of 4 before grouping. "110" โ†’ "0110" โ†’ 0x6, not 0xC.
  • Misreading the bit-length. The bit-length is the position of the highest 1 plus 1, not the number of characters in the input. An input of "0001010" still has bit-length 4.
  • Treating hex digits as letters. A = 10, B = 11, ..., F = 15. Confusing B with 11, or 1 with I, is a common transcription error.
  • Endianness. Hex dumps of multi-byte values can be little-endian or big-endian. The converted value is the same integer either way; the written order is what differs.

Frequently Asked Questions

What is the difference between binary, octal, decimal, and hexadecimal?

They are all positional number systems using different bases: binary is base 2 (digits 0, 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 plus A-F for 10 to 15). The same integer has a different written form in each base.

Why is hexadecimal so popular in computing?

Hexadecimal aligns neatly with binary: one hex digit equals exactly four binary bits. So a 32-bit value can be written as 8 hex digits instead of 32 binary digits. Memory addresses, hash values, and colour codes are all routinely written in hex.

Can this converter handle negative numbers?

No, this tool treats all inputs as non-negative integers. For signed representations (two's complement), you would need to specify a bit-width and interpret the high bit as a sign.

What is the largest number this tool can handle?

It uses JavaScript BigInt, which has no fixed upper bound. The practical limit is your browser's memory and patience, strings of millions of digits will work but slowly.

How do I convert binary to octal quickly?

Group the binary digits into sets of three from the right, padding with zeros on the left if needed, then read each group as an octal digit. Example: 101100 โ†’ 101 100 โ†’ 54โ‚ˆ.

What does the 0x prefix mean?

The 0x prefix marks a literal as hexadecimal in many programming languages (C, C++, Java, JavaScript, Python, Rust). It's not part of the value itself, 0x10 and 10x would mean the same number (16), but the prefix tells the reader (and the compiler) which base to use.

How do I convert from base 10 to base 2 by hand?

Repeatedly divide by 2 and record the remainders; the remainders read bottom-up are the binary digits. Example: 10 รท 2 = 5 r 0; 5 รท 2 = 2 r 1; 2 รท 2 = 1 r 0; 1 รท 2 = 0 r 1. Read bottom-up: 1010.

Why is octal rare in modern code?

Octal was popular when computers had 12, 24, or 36-bit words (each cleanly divisible by 3). With the dominance of 8-bit bytes and 32/64-bit words, hex (divisible by 4) became the natural fit. Octal survives in Unix file permissions (which are 3 bits per group: owner, group, other) and a few legacy contexts.

Does whitespace in the input matter?

No, the converter strips all whitespace before parsing, so "DE AD BE EF" works the same as "DEADBEEF". This is convenient for pasting long hex hashes from logs.

What about uppercase vs lowercase hex?

Both are accepted. The output is normalized to uppercase by convention, but the parsing is case-insensitive (so "deadbeef" and "DEADBEEF" both produce 0xDEADBEEF).

References

  • IEEE 754, floating-point representation standard (not used here; this tool is integer-only).
  • Donald Knuth, The Art of Computer Programming, Vol 2, ยง4.4, positional number systems.
  • Wikipedia, "Positional notation", accessible overview of base systems.
  • RFC 4648, Base16, Base32, Base64 data encodings (close cousin of hex).
  • Intelยฎ 64 and IA-32 Architectures Software Developer's Manual, practical hex/binary conventions in x86 assembly.