Forum Discussion
Do you know how to convert binary numbers to decimal?
It's easy with the BIN2DEC function, but there's a limitation and an easy way to make a mistake and get a wrong result. The limitation is that it can't convert a number with more than 10 bits. If you try, it will give an error. There's also an easy way to make a mistake. If you use numbers that have 10 bits, they may be converted to a negative number. For an explanation, you need to understand the "Two's complement" method of representing binary integers.
I found this article by Excel MVP Frédéric LE GUEN, that provides a workaround to the 10 bit limitation of the BIN2DEC function:
Convert Binary Number to Decimal in Excel :keycap_0: :keycap_1: (excel-tutorial.com)
I suspect DEC2BIN is now largely superseded by
= BASE(targetDec, 2) = DECIMAL(targetBin, 2)
6 Replies
- NikolinoDEPlatinum Contributor
Alternative with a different formula: =BinaryToDecimal(A1)

Example file inserted.
- Patrick2788Silver Contributor
At present I prefer this method:
=MOD(BITRSHIFT(numbers,SEQUENCE(,10,9,-1)),2)I realize it can be done with MOD and simple division but I like the way this reads. I used this method in a project I'm working on where it needed to generate 1 million + bin elements and it performed well. It's good to give BITRSHIFT some exercise, too!
- PeterBartholomew1Silver Contributor
I wouldn't say I prefer the proposed method, but it is more interesting and expresses key concepts with elegance.
I rather regret not using
= VSTACK( BITLSHIFT(combination0, 1) + 1, BITLSHIFT(combination1, 1) )to combine two lists of combinations, following Pascal's triangle. Timing runs showed
= VSTACK( 2 * combination0 + 1, 2 * combination1 )to be faster.
- PeterBartholomew1Silver Contributor
I suspect DEC2BIN is now largely superseded by
= BASE(targetDec, 2) = DECIMAL(targetBin, 2)PeterBartholomew1 - thank you for mentioning those. I had not used them before, but I agree with you.
- NikolinoDEPlatinum Contributor
The BIN2DEC function is indeed handy, but it has its limitations, as you mentioned.
To overcome the limitation of BIN2DEC function for numbers with more than 10 bits, you can use a custom formula or a workaround. Frédéric LE GUEN's article likely provides a workaround for this limitation.
One common workaround is to use Excel's built-in ability to handle bitwise operations. You can use a combination of functions like BITAND, BITLSHIFT, and BITOR along with some arithmetic to convert binary numbers of any length to decimal.
Using BITAND, BITLSHIFT, and BITOR functions to convert a binary number of any length to decimal.
Here is a step-by-step guide:
- Input: Assume we have a binary number represented as a string of 1s and 0s in cell A1. For example, "110101".
- Convert Binary to Decimal:
To convert this binary number to decimal, we can use the following formula:
=SUMPRODUCT(--MID(A1,LEN(A1)-ROW($1:$LEN(A1))+1,1)*BITLSHIFT(1,ROW($1:$LEN(A1))-1))
Let us break down this formula:
- MID(A1,LEN(A1)-ROW($1:$LEN(A1))+1,1): This extracts each digit of the binary number starting from the rightmost digit.
- --: This converts the extracted binary digits to numbers.
- BITLSHIFT(1,ROW($1:$LEN(A1))-1): This generates an array of powers of 2 corresponding to the position of each digit.
- SUMPRODUCT: This multiplies each binary digit by its corresponding power of 2 and then sums the results, effectively converting the binary number to decimal.
- Result: If cell A1 contains the binary number "110101", applying the formula will return the decimal equivalent, which is 53.
You can input different binary numbers in cell A1 to test the formula and verify the conversion to decimal. This method allows you to convert binary numbers of any length to decimal in Excel.Formularbeginn The text and steps were edited with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.