How to convert binary to decimal & vice versa?

H

hmmm

hi!

i wonder if anyone has ever tried to convert binary no. to decimal
vice versa in excel?

Thanks
 
S

swatsp0p

If you have the Analysis ToolPak add-in installed, it has two functions
just for this:

dec2bin and bin2dec

HTH

Bruce
 
H

hmmm

hey thanks so much!

yup sure enough, i got the #Name error and had to add the additiona
feature frm the EXCEL installer.

if anyone else has another solution, do share it with me! thanks again
 
H

Harlan Grove

hmmm wrote...
i wonder if anyone has ever tried to convert binary no. to decimal &
vice versa in excel?

If you just want to go up to 2^16-1, one purely built-in way to convert
the decimal number x to binary is

=MOD(INT(x/2^15),2)&MOD(INT(x/2^14),2)&MOD(INT(x/2^13),2)&MOD(INT(x/2^12),2)
&MOD(INT(x/2^11),2)&MOD(INT(x/2^10),2)&MOD(INT(x/2^9),2)&MOD(INT(x/2^8),2)
&MOD(INT(x/2^7),2)&MOD(INT(x/2^6),2)&MOD(INT(x/2^5),2)&MOD(INT(x/2^4),2)
&MOD(INT(x/2^3),2)&MOD(INT(x/2^2),2)&MOD(INT(x/2),2)&MOD(x,2)

And to convert the binary number b to decimal,

=SUMPRODUCT(MID(b,ROW(INDIRECT("1:"&LEN(b))),1)
*2^(LEN(b)-ROW(INDIRECT("1:"&LEN(b)))))
 
M

MrShorty

Converting from binary to decimal is a simple "sumproduct."

(Working from right to left) 1101=1*2^0+0*2^1+1*2^2+1*2^3=13

There are a few different algorithms for converting decimal to binary.
Involves dividing repeatedly by 2 and noting the remainder (or noting if
the number is even, or however you want to look at it). These
algorithms are described in several places on the net. Put "convert
decimal to binary" in your favorite search engine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top