Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function GetPI() As Double
'returns the value of PI to 14 decimal places
GetPI = (4 * Atn(1))
End Function
Public Function RoundDblToSng(ByVal nValue As Double, _
nDigits As Long) As Single
'returns the passed value rounded to n decimal
'places. From a msnews post by Steve Anderson.
'Useful for versions of VB without the Round
'function, or when customized return is required.
RoundDblToSng = Int(nValue * (10 ^ nDigits) + 0.5) / (10 ^ nDigits)
End Function
Public Function ShiftBitsLeft(ByVal dwValue As Long, _
ByVal dwBitsLeft As Long) As Long
'bitwise left-shift equivalent to
'C++ << operator
ShiftBitsLeft = CLng(dwValue * (2 ^ dwBitsLeft))
End Function
Public Function ShiftBitsRight(ByVal dwValue As Long, _
ByVal dwBitsRight As Long) As Long
'bitwise right-shift equivalent to
'C++ >> operator
ShiftBitsRight = CLng(dwValue / (2 ^ dwBitsRight))
End Function
|