Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using the following function to convert from deciminal to binary.
It works great for small numbers but when I send it a decimal value that I want convered to 32 binary digits the result that comes out is only 16 binary bits. Is there a way to make this function support 32 bit binary? Or is there another function I can replace it with? Function Dec2Bin(ByVal DecimalIn As Variant, _ Optional NumberOfBits As Variant) As String Dec2Bin = "" DecimalIn = Int(CDec(DecimalIn)) Do While DecimalIn < 0 Dec2Bin = Format$(DecimalIn - 2 * Int(DecimalIn / 2)) & Dec2Bin DecimalIn = Int(DecimalIn / 2) Loop If Not IsMissing(NumberOfBits) Then If Len(Dec2Bin) NumberOfBits Then Dec2Bin = "Error - Number exceeds specified bit size" Else Dec2Bin = Right$(String$(NumberOfBits, _ "0") & Dec2Bin, NumberOfBits) End If End If End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
3 bits of data | Excel Discussion (Misc queries) | |||
What 'value' is a Dec2Bin output? | Excel Discussion (Misc queries) | |||
=Dec2bin can you increase the number bits please | Excel Discussion (Misc queries) | |||
How to get leading zeros using DEC2BIN | Excel Worksheet Functions | |||
Base number functions, example DEC2BIN | Setting up and Configuration of Excel |