VBspeed / Util / Pow2
VBspeed © 2000-10, updated: 18-Dec-2000
Pow2


Pow2
Raise 2 to a power. The exponent must be in the range [0,31]. Added 18-Dec-2000
Doping: none
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
Author's comments:
Donald's comments:


VBspeed © 2000-10 by Donald Lessau