|
2#
楼主 |
发表于 2015-8-9 11:19:13
|
只看该作者
这个我目前收集到VBA速度最快的二进制转十进制, 德国人写的, 但可惜只能定长字符串(32字符长度)
当然这是我收集,不是我写的, 如果要重写定长转换, 速度还是很容易超过它的. 但定长的实用性不强, 写出后意义也不大.
Public Function BitToLong04(bitexpr As String) As Long
' by G.Beckmann, G.Beckmann@NikoCity.de, 20001230
' based on BitToLong03 by Egbert Nierop, egbert_nierop@goovy.hotmail.com, 20001228
Static t%(31): Dim asc0%
If Len(bitexpr) <> 32 Then Exit Function
RtlMoveMemory t(0), ByVal StrPtr(bitexpr), 64
asc0 = KeyCodeConstants.vbKey0
BitToLong04 = t(1) - asc0
BitToLong04 = 2 * BitToLong04 + t(2) - asc0
BitToLong04 = 2 * BitToLong04 + t(3) - asc0
BitToLong04 = 2 * BitToLong04 + t(4) - asc0
BitToLong04 = 2 * BitToLong04 + t(5) - asc0
BitToLong04 = 2 * BitToLong04 + t(6) - asc0
BitToLong04 = 2 * BitToLong04 + t(7) - asc0
BitToLong04 = 2 * BitToLong04 + t(8) - asc0
BitToLong04 = 2 * BitToLong04 + t(9) - asc0
BitToLong04 = 2 * BitToLong04 + t(10) - asc0
BitToLong04 = 2 * BitToLong04 + t(11) - asc0
BitToLong04 = 2 * BitToLong04 + t(12) - asc0
BitToLong04 = 2 * BitToLong04 + t(13) - asc0
BitToLong04 = 2 * BitToLong04 + t(14) - asc0
BitToLong04 = 2 * BitToLong04 + t(15) - asc0
BitToLong04 = 2 * BitToLong04 + t(16) - asc0
BitToLong04 = 2 * BitToLong04 + t(17) - asc0
BitToLong04 = 2 * BitToLong04 + t(18) - asc0
BitToLong04 = 2 * BitToLong04 + t(19) - asc0
BitToLong04 = 2 * BitToLong04 + t(20) - asc0
BitToLong04 = 2 * BitToLong04 + t(21) - asc0
BitToLong04 = 2 * BitToLong04 + t(22) - asc0
BitToLong04 = 2 * BitToLong04 + t(23) - asc0
BitToLong04 = 2 * BitToLong04 + t(24) - asc0
BitToLong04 = 2 * BitToLong04 + t(25) - asc0
BitToLong04 = 2 * BitToLong04 + t(26) - asc0
BitToLong04 = 2 * BitToLong04 + t(27) - asc0
BitToLong04 = 2 * BitToLong04 + t(28) - asc0
BitToLong04 = 2 * BitToLong04 + t(29) - asc0
BitToLong04 = 2 * BitToLong04 + t(30) - asc0
BitToLong04 = t(31) - asc0 + 2 * BitToLong04
If t(0) <> asc0 Then BitToLong04 = BitToLong04 Or &H80000000
End Function
|
|