Class BitUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte
clearBit
(byte i, int num) static char
clearBit
(char i, int num) static int
clearBit
(int i, int num) static long
clearBit
(long i, int num) static short
clearBit
(short i, int num) static boolean
isBitSet
(byte i, int num) returns true is specified bit in the specified byte is set.static boolean
isBitSet
(char i, int num) static boolean
isBitSet
(int i, int num) static boolean
isBitSet
(long i, int num) static boolean
isBitSet
(short i, int num) static void
static byte
setBit
(byte i, int num) static char
setBit
(char i, int num) static int
setBit
(int i, int num) static long
setBit
(long i, long num) static short
setBit
(short i, int num) static String
toBinaryString
(byte i) static String
toBinaryString
(byte i, String format) returns a 8 char binary digit string.static String
toBinaryString
(char i) returns a 16 char binary digit stringstatic String
toBinaryString
(char i, String format) returns a 16 char binary digit string.static String
toBinaryString
(int i) returns a 32 char binary digit string (Integer.toBinaryString is not padded, can be less than 32 chars)static String
toBinaryString
(int i, String format) returns a 32char binary digit string (Long.toBinaryString is not padded, can be less than 32 chars).static String
toBinaryString
(long i) returns a 64 char binary digit string (Long.toBinaryString is not padded, can be less than 64 chars))static String
toBinaryString
(long i, String format) returns a 64 char binary digit string (Long.toBinaryString is not padded, can be less than 64 chars).static String
toBinaryString
(short i) returns a 16 char binary digit stringstatic String
toBinaryString
(short i, String format) returns a 16 char binary digit string.
-
Constructor Details
-
BitUtil
public BitUtil()
-
-
Method Details
-
isBitSet
returns true is specified bit in the specified byte is set. The num parameter is the bit position (0-based index). Set means the bit has value 1. -
isBitSet
-
isBitSet
-
isBitSet
-
isBitSet
-
setBit
-
setBit
-
setBit
-
setBit
-
setBit
-
clearBit
-
clearBit
-
clearBit
-
clearBit
-
clearBit
-
toBinaryString
-
toBinaryString
returns a 16 char binary digit string -
toBinaryString
returns a 16 char binary digit string -
toBinaryString
returns a 32 char binary digit string (Integer.toBinaryString is not padded, can be less than 32 chars) -
toBinaryString
returns a 64 char binary digit string (Long.toBinaryString is not padded, can be less than 64 chars)) -
toBinaryString
returns a 8 char binary digit string.The format string has a number and separator, like "4 " which will print chunks of size
with the specified . The number must be between [1-9] and separator must be a single character, like: | or space. Errors in the format string are ignored and default values are used instead (4 and space). -
toBinaryString
returns a 16 char binary digit string.The format string has a number and separator, like "4 " which will print chunks of size
with the specified . The number must be between [1-9] and separator must be a single character, like: | or space. Errors in the format string are ignored and default values are used instead (4 and space). -
toBinaryString
returns a 16 char binary digit string.The format string has a number and separator, like "4 " which will print chunks of size num with the specified separator.
-
toBinaryString
returns a 32char binary digit string (Long.toBinaryString is not padded, can be less than 32 chars).The format string has a number and separator, like "4 " which will print chunks of size
with the specified . The number must be between [1-9] and separator must be a single character, like: | or space. Errors in the format string are ignored and default values are used instead (4 and space). -
toBinaryString
returns a 64 char binary digit string (Long.toBinaryString is not padded, can be less than 64 chars).The format string has a number and separator, like "4 " which will print chunks of size
with the specified . The number must be between [1-9] and separator must be a single character, like: | or space. Errors in the format string are ignored and default values are used instead (4 and space). -
main
-