Binary to Decimal Converter

The decimal and hex value of any binary number, spaces ignored.

How it is calculated

The input is stripped of all spaces, so 1111 0000 is read as 11110000. It must then consist only of the digits 0 and 1. The value is computed as decimal = Σ dᵢ × 2i, where dᵢ is the digit at position i counted from the right starting at 0. The hexadecimal output is the same number written in base 16 with an 0x prefix and upper-case letters. Leading zeros are ignored, and an input of only zeros gives 0 (0x0). The converter handles unsigned values of up to 63 binary digits after leading zeros are removed, i.e. up to 9223372036854775807; a longer string, or one containing any other character (a minus sign, a decimal point, the digit 2), returns no result. It does not interpret the leading bit as a sign.

Worked example

Take 110101101, which has nine digits. Reading from the left, the place values are 256, 128, 64, 32, 16, 8, 4, 2, 1 and the digits are 1, 1, 0, 1, 0, 1, 1, 0, 1. Adding the places holding a 1 gives 256 + 128 + 32 + 8 + 4 + 1 = 429. Regrouping the bits in fours from the right (1 / 1010 / 1101) gives the hex digits 1, A and D, so the hex output is 0x1AD.

Try this example →

Common mistakes

  • Pasting a binary number with a prefix such as 0b or a trailing b. Only 0 and 1 are accepted, so the letter makes the input invalid; remove the prefix first.
  • Expecting two's-complement negative numbers. A string like 11111111 is read as 255, not -1, because the tool never treats the leading bit as a sign.
  • Entering fractional binary such as 101.1. A point is rejected; the tool only converts whole numbers.
  • Counting positions from the left instead of the right. The rightmost digit is worth 1, so reversing the string gives a completely different value.
  • Pasting a 64-bit all-ones value. Anything longer than 63 digits after leading zeros is refused rather than rounded.

About this calculator

Binary (base 2) represents every number using only 0s and 1s, where each digit's place value doubles moving left — 1, 2, 4, 8, 16... To convert to decimal (base 10), you multiply each binary digit by its place value and sum the results (e.g. 1011₂ = 1×8 + 0×4 + 1×2 + 1×1 = 11); converting to hexadecimal (base 16) groups the binary digits into sets of four, each mapping directly to one hex digit (0-9, A-F).

Computer science students learn this conversion as a foundation for understanding how computers represent data, while programmers, network engineers, and hardware/firmware developers use it routinely to read memory addresses, IP subnet masks, bitwise flags, and register values that are natively expressed in binary or hex.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Network work is a typical use, with one catch: dotted notation is rejected, so convert each octet separately. In a subnet mask, 11111000 gives 248 (0xF8) and 11111111 gives 255, which is how a mask of 255.255.248.0 is read. Eight ones always give 255 and eight zeros give 0. Here the octet shows how many network bits are set. Are you decoding masks and addresses, or flags and register values?

Popular calculators

All Calculators