当我将此二进制转换为十进制时:
0100000101101100011010010010000001000001011010000110110101100101011001000010000001001111011100110110110101100001000010110111000100000011000100100100100110011001001110100011010000110010001100001011101000110010100101101100010001001011010011001100101101101100100100110110100110110100110110110110110110110110110110100110110110110110110100110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110100110110110110110100
使用VB.Net,我得到这个双重数字:three
。
我需要将其格式化为普通数字,如下所示:
10069595034014783469636931351646363690636553221072125712116008033168565762469882090200055592025448896479090348155246
如何使用PHP或VB.Net做到这一点?
1.00695950340148E+115
输出为:
Visual Basic.Net编译器版本0.0.0.5943(Mono 4.7-tarball)
版权所有(C)2004-2010 Rolf Bjarne Kvinge。保留所有权利。
程序集'jdoodle,Version = 0.0,Culture = neutral,PublicKeyToken = null' 已成功保存到“ /home/jdoodle.exe”。编译成功
编译时间为00:00:01.1970230
x和y的和= 1.00695950340148E + 115
答案 0 :(得分:0)
请尝试使用此方法,但我尚未验证它是否正确:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myBin = "110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111110101010100001111101010101010101000000110110101100000010111"
Debug.Print(ConvBinToDec(myBin))
End Sub
Function ConvBinToDec(ByVal theVal As String)
ConvBinToDec = ""
Dim BinVal(Len(theVal)) As String
BinVal(1) = "1"
Dim Total = "0"
If Mid(theVal, Len(theVal), 1) = "1" Then Total = "1"
Dim myLast As String = ""
For a = 2 To Len(theVal)
BinVal(a) = Multi(BinVal(a - 1))
myLast = BinVal(a)
If Mid(theVal, Len(theVal) - a + 1, 1) = "1" Then
Total = Adding(Total, myLast)
End If
Next
ConvBinToDec = Total
End Function
Function Multi(ByVal TheVal As String) As String
Dim simpan As Byte = 0
Multi = ""
Dim myLen As Byte = 10
Dim myTimes = -Int(-Len(TheVal) / myLen)
For a = 1 To myTimes
Dim myStr As String = Strings.Right(TheVal, a * myLen)
Dim myRemain As String = Strings.Left(myStr, Len(myStr) - (a - 1) * myLen)
Multi = Strings.Right("0000000000" & CLng(myRemain) * 2 + simpan, myLen) & Multi
If Len(CStr(CLng(myRemain) * 2 + simpan)) > myLen Then simpan = 1 Else simpan = 0
If a = myTimes And simpan = 1 Then Multi = "1" & Multi
Next
End Function
Function Adding(ByVal TheVal1 As String, ByVal TheVal2 As String) As String
Dim simpan As Byte = 0
Adding = ""
Dim myLen As Byte = 10
Dim myTimes = -Int(-Len(TheVal2) / myLen)
TheVal1 = Strings.Right("00000000000" & TheVal1, Len(TheVal2))
For a = 1 To myTimes
Dim myStr1 As String = Strings.Right(TheVal1, a * myLen)
Dim myStr2 As String = Strings.Right(TheVal2, a * myLen)
Dim myRemain1 As String = Strings.Left(myStr1, Len(myStr1) - (a - 1) * myLen)
Dim myRemain2 As String = Strings.Left(myStr2, Len(myStr2) - (a - 1) * myLen)
Adding = Strings.Right("0000000000" & CLng(myRemain1) + CLng(myRemain2) + simpan, myLen) & Adding
If Len(CStr(CLng(myRemain1) + CLng(myRemain2) + simpan)) > myLen Then simpan = 1 Else simpan = 0
If a = myTimes And simpan = 1 Then Adding = "1" & Adding
Next
End Function
当我尝试使用您的二进制文件时,
"010000010110110001101001001000000100000101101000011011010110010101100100001000000100111101110011011011010110000101101110001000000110001001101001011100100111010001101000011001000110000101110100011001010011101000110001001011010011001100101101001100010011100100111000001101110010000001100011011011110111010101101110011101000111001001111001001110100111001101110101011001000110000101101110"
结果是:
"000010069595034014783469636931351646363690636553221072125712116008033168565762469882090200055592025448896479090348155246"