public class BitMaskUtil extends Object
Constructor and Description |
---|
BitMaskUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
getMaskForBit(int bitNumber) |
static boolean |
isBitOn(int value,
int bitNumber)
Check if the bit is set to '1'
|
static int |
setBit(int value,
int bitNumber,
boolean bitValue)
Set bit to '0' or '1' in the given int.
|
static int |
setBitOff(int value,
int bitNumber)
Set bit to '0' in the given int.
|
static int |
setBitOn(int value,
int bitNumber)
Set bit to '1' in the given int.
|
public static int setBitOn(int value, int bitNumber)
current
- integer valuebitNumber
- number of the bit to set to '1' (right first bit starting at 1).public static int setBitOff(int value, int bitNumber)
current
- integer valuebitNumber
- number of the bit to set to '0' (right first bit starting at 1).public static boolean isBitOn(int value, int bitNumber)
value
- integer to check bitnumber
- of bit to check (right first bit starting at 1)public static int setBit(int value, int bitNumber, boolean bitValue)
current
- integer valuebitNumber
- number of the bit to set to '0' or '1' (right first bit starting at 1).bitValue
- if true, bit set to '1'. If false, '0'.public static int getMaskForBit(int bitNumber)
Copyright © 2019. All rights reserved.