'Unlimitedly large decimal to binary Functions
'Call example:
& Apos; debug. Print bigdec_to_bin ("79228162514264337593543950335 ")
& Apos; debug. Print bigdec_to_bin ("7922816251426433759354395033579228162514264337593543950335 ")
'Reference Article http://blog.csdn.net/chinaboyzyq/archive/2010/03/22/5403914.aspx
Public Function bigdec_to_bin (byval dec as string) as string
Dim I as long
'Dim strdec as string
Dim strret as string
Dim strmod as string
Do
Strret = "": strmod = ""
Bigdiv2 Dec, strret, strmod
Dec = strret
Bigdec_to_bin = strmod & bigdec_to_bin
Doevents
Loop until strret = "0"
End Function
Private sub bigdiv2 (byval dec as string, strret as string, strmod as string)
Dim I as long
Dim strtmp as string
Strmod = 0
For I = 1 to Len (DEC)
Strret = strret & (Val (mid (Dec, I, 1) + strmod * 10)/2
Strmod = (Val (mid (Dec, I, 1) + strmod * 10) mod 2
Next
If left (strret, 1) = "0" and Len (strret)> 1 then strret = right (strret, Len (strret)-1)
End sub