DEC2BIN Function for numbers to 80,000??

  • Thread starter Thread starter Tom M
  • Start date Start date
T

Tom M

The function in Excel 2000 only converts to 10 digits
(bits) or 511 decimal. Anyone know how to increase the
range up to 80,000 or 100,000 ?? or up to 32 bits thanks
 
Here is brute force approach to convert up to 10 decimal digits to
binary. You could modify it to a specific word size to handle negative
numbers.

Function D2B(ByVal n As Long) As String
n = Abs(n)
D2B = ""
Do While n > 0
If n = (n \ 2) * 2 Then
D2B = "0" & D2B
Else
D2B = "1" & D2B
n = n - 1
End If
n = n / 2
Loop
End Function

Jerry
 
One way:

for 32 bits:

=DEC2BIN(A1/512^3,5) & DEC2BIN(INT(MOD(A1,512^3)/512^2),9) &
DEC2BIN(INT(MOD(A1,512^2)/512),9) & DEC2BIN(MOD(A1,512),9)


Note: 32 bits represents 2^32-1 or 4,294,967,295 which is
significantly larger than 80,000 or 100,000

To cover 80,000 (or 100,000) only requires 17 bits:

=DEC2BIN(A1/512,8)&DEC2BIN(MOD(A1,512),9)
 
If i want to show 13bits, how can i do that? i don't know how to calcaulate it. thanks for your help
 
Back
Top