0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

演算処理:ビットチェック

Last updated at Posted at 2025-04-23

ビットチェック

数値の内で、指定したビットがONとなっているかをチェックする。
一部一致か完全一致の指定あり

'------------------------------------------------------------------------------
' ビットチェック
'------------------------------------------------------------------------------
Public Function F_CheckBitOn( _
        ByVal aNum As Long, ByVal aCheck As Long, _
        Optional ByVal aMask As Long = &H0, _
        Optional ByVal aChkSpec As E_CHECK = E_CHECK_OR) As Boolean
    Dim wkRet As Long
    Dim wkMask As Long
    
    If aChkSpec = E_CHECK_OR Then
        wkRet = ((aNum And aCheck) > 0)
    Else
        wkMask = aMask
        If wkMask = &H0 Then
            wkMask = aCheck
        End If
        
        wkRet = ((aNum And wkMask) = aCheck)
    End If
    
    F_CheckBitOn = wkRet
End Function
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?