Ответить на сообщение
Вернуться к теме
Вы отвечаете на сообщение:
ник: Lukas Спасибо Олег. Еще не надоели мои мысли-скакуны? Предлагаю экзотику, работает на 37% быстрее последней LongToBinStr и на 70% быстрее ToBinary:
Public Function LongToBinStr16(ByVal Number As Long, Optional Digits As Long = 32) As String Dim i As Long Const ZERO As String * 1 = "0" Const ONE As String * 4 = "0001" Const TWO As String * 4 = "0010" Const THREE As String * 4 = "0011" Const FOUR As String * 4 = "0100" Const FIVE As String * 4 = "0101" Const SIX As String * 4 = "0110" Const SEVEN As String * 4 = "0111" Const EIGHT As String * 4 = "1000" Const NINE As String * 4 = "1001" Const TEN As String * 4 = "1010" Const ELEVEN As String * 4 = "1011" Const TWELVE As String * 4 = "1100" Const THIRTEEN As String * 4 = "1101" Const FOURTEEN As String * 4 = "1110" Const FIFTEEN As String * 4 = "1111" LongToBinStr16 = String(Digits + 3, ZERO) For i = Digits To 1 Step -4 Select Case Number Mod 16 Case Is = 1: Mid$(LongToBinStr16, i, 4) = ONE Case Is = 2: Mid$(LongToBinStr16, i, 4) = TWO Case Is = 3: Mid$(LongToBinStr16, i, 4) = THREE Case Is = 4: Mid$(LongToBinStr16, i, 4) = FOUR Case Is = 5: Mid$(LongToBinStr16, i, 4) = FIVE Case Is = 6: Mid$(LongToBinStr16, i, 4) = SIX Case Is = 7: Mid$(LongToBinStr16, i, 4) = SEVEN Case Is = 8: Mid$(LongToBinStr16, i, 4) = EIGHT Case Is = 9: Mid$(LongToBinStr16, i, 4) = NINE Case Is = 10: Mid$(LongToBinStr16, i, 4) = TEN Case Is = 11: Mid$(LongToBinStr16, i, 4) = ELEVEN Case Is = 12: Mid$(LongToBinStr16, i, 4) = TWELVE Case Is = 13: Mid$(LongToBinStr16, i, 4) = THIRTEEN Case Is = 14: Mid$(LongToBinStr16, i, 4) = FOURTEEN Case Is = 15: Mid$(LongToBinStr16, i, 4) = FIFTEEN End Select Number = Number \ 16 If Number = 0 Then GoTo ExitFunction Next i ExitFunction: LongToBinStr16 = Mid$(LongToBinStr16, 4) End Function
Ваше имя:
Пароль:
Сообщение:
Прикрепить:
Для вставки смайлов в текст щелкните по значку.