• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Create a Custom Function

XLPadawan

Member
Excel's DEC2BIN function only allows for binary number lengths up to 10 digits. How would I make a function from the code I've provided that would allow me to replace the DEC2BIN function used on the UseNewFunc tab and extend it downward to eliminate the #NUM! errors? The arguments for the function (in columns A and D) would be supplied to cell D6 (in tab DEC2BINX), returning the result from H3 as the function value.
 

Attachments

Hi ,

The uploaded file does not seem to relate to what ever you have posted ; there is no UseNewFunc tab , no DEC2BINX tab , and it is not clear what your real requirement is.

If you can give a clear explanation to the following questions , it will help.

1. You wish to convert a decimal number to a binary number ; is this correct ?

2. If yes , then what are the lower and upper limits for the decimal number ?

3. How are negative numbers to be treated , or will the numbers be strictly positive ?

4. Do you want only a conversion function or will you be doing any further arithmetic operations on the binary numbers ? For example , will you have a formula such as =DEC2BINX(NumA) + DEC2BINX(NumB) ?

Narayan
 
The file I have DOES have the tabs I referenced. I'll upload again and see what happens. If it uploads correctly, it should answer all your questions.
 

Attachments

You can use DEC2BIN for longer digits. You just have to break it down into 8 bit segments.

For 16 bit:
Code:
=DEC2BIN(INT(A1/2^8),8)&DEC2BIN(MOD(A1,2^8),8)
 
You can use DEC2BIN for longer digits. You just have to break it down into 8 bit segments.

For 16 bit:
Code:
=DEC2BIN(INT(A1/2^8),8)&DEC2BIN(MOD(A1,2^8),8)

Good stuff, Chihiro. Although I didn't mention it, I was hoping to see how to make a custom function and apply that knowledge to other [functions] I've created. Thanks!
 
Back
Top