You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
474 B
25 lines
474 B
package util |
|
|
|
//IsBitSet bit is from 0 to 31 |
|
func IsBitSet(attr int, bit uint) bool { |
|
return IsBitSet64(int64(attr), bit) |
|
} |
|
|
|
// IsBitSet64 bit is from 0 to 63 |
|
func IsBitSet64(attr int64, bit uint) bool { |
|
if bit >= 64 { |
|
return false |
|
} |
|
|
|
return (attr & (1 << bit)) != 0 |
|
} |
|
|
|
//SetBit64 set bit to 1 |
|
func SetBit64(attr int64, bit uint) int64 { |
|
return attr | (1 << bit) |
|
} |
|
|
|
//UnSetBit64 set bit to 0 |
|
func UnSetBit64(attr int64, bit uint) int64 { |
|
return attr & ^(1 << bit) |
|
}
|
|
|