ifix的字的拆位程序 点击:619 | 回复:2



EDGARi2u

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 8回
  • 年度积分:0
  • 历史总积分:222
  • 注册:2007年6月05日
发表于:2008-08-06 15:14:10
楼主
Public Function GET_BIT(DecimalValue As Long, bitN As Long) As Long '取位
Dim land As Long
land = 2 ^ bitN
GET_BIT = (DecimalValue And land) / land

End Function
Public Function SET_BIT(DecimalValue As Long, bitN As Long) As Long '置位

Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 0 Then
SET_BIT = DecimalValue + land
Else: SET_BIT = DecimalValue
End If
End Function

Public Function RESET_BIT(DecimalValue As Long, bitN As Long) As Long '复位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 1 Then
RESET_BIT = DecimalValue - land
Else: RESET_BIT = DecimalValue
End If
End Function
Public Function CHANGE_BIT(DecimalValue As Long, bitN As Long) As Long '复位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 1 Then
CHANGE_BIT = DecimalValue - land
Else: RESET_BIT = DecimalValue + land
End If
End Function



EDGARi2u

  • 精华:0帖
  • 求助:0帖
  • 帖子:3帖 | 8回
  • 年度积分:0
  • 历史总积分:222
  • 注册:2007年6月05日
发表于:2008-08-06 15:14:46
1楼
Public Function GET_BIT(DecimalValue As Long, bitN As Long) As Long '取位
Dim land As Long
land = 2 ^ bitN
GET_BIT = (DecimalValue And land) / land

End Function
Public Function SET_BIT(DecimalValue As Long, bitN As Long) As Long '置位

Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 0 Then
SET_BIT = DecimalValue + land
Else: SET_BIT = DecimalValue
End If
End Function

Public Function RESET_BIT(DecimalValue As Long, bitN As Long) As Long '复位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 1 Then
RESET_BIT = DecimalValue - land
Else: RESET_BIT = DecimalValue
End If
End Function
Public Function CHANGE_BIT(DecimalValue As Long, bitN As Long) As Long '换位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 1 Then
CHANGE_BIT = DecimalValue - land
Else: RESET_BIT = DecimalValue + land
End If
End Function

club

  • 精华:0帖
  • 求助:0帖
  • 帖子:47帖 | 739回
  • 年度积分:0
  • 历史总积分:0
  • 注册:1900年1月01日
发表于:2008-08-23 16:28:52
2楼

学习了,但还是看不懂


热门招聘
相关主题

官方公众号

智造工程师