Public Function BitGet(ByVal Variable As Long, ByVal BitNum As Byte) As Byte
BitGet = Abs(CBool(Variable And 2 ^ BitNum))
End Function
Public Function BitSet(ByVal Variable As Long, ByVal BitNum As Byte) As Long
BitSet = Variable Or 2 ^ BitNum
End Function
Public Function BitClear(ByVal Variable As Long, ByVal BitNum As Byte) As Long
BitClear = Variable And Not (2 ^ BitNum)
End Function
Public Function BitGet(ByVal Variable As Long, ByVal BitNum As Byte) As Byte
BitGet = Variable And 2 ^ BitNum
End Function
Option Explicit
Public Function test()
Dim i&, n&, t!
n = 1000000
t = Timer()
For i = 1 To n
Call routine_for_test_1(Parameters)
Next
Debug.Print Timer() - t
t = Timer()
For i = 1 To n
Call routine_for_test_2(Parameters)
Next
Debug.Print Timer() - t
End Function
Dim SH(31) As Long
Public Sub Ini()
Dim n As Integer
For n = 0 To 30
SH(n) = 2 ^ n
Next n
SH(31) = &H80000000
End Sub
Public Function BG(ByVal Variable As Long, ByVal BitNum As Byte) As Byte
BG = -CBool(Variable And SH(BitNum))
End Function
Public Function BS(ByVal Variable As Long, ByVal BitNum As Byte) As Long
BS = Variable Or SH(BitNum)
End Function
Public Function BC(ByVal Variable As Long, ByVal BitNum As Byte) As Long
BC = Variable And Not SH(BitNum)
End Function
Mikle писал(а):
- Код: Выделить всё
Dim SH(31) As Long
...
Сейчас этот форум просматривают: AhrefsBot, SemrushBot и гости: 11