Public Static Function Pow2(ByVal Exponent As Long) As Long
' by Donald, donald@xbeat.net, 20001217
' * Power205
Dim alPow2(0 To 31) As Long
Dim i As Long
Select Case Exponent
Case 0 To 31
' initialize lookup table
If alPow2(0) = 0 Then
alPow2(0) = 1
For i = 1 To 30
alPow2(i) = alPow2(i - 1) * 2
Next
alPow2(31) = &H80000000
End If
' return
Pow2 = alPow2(Exponent)
End Select
End Function
|