File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
src/main/java/com/thealgorithms/bitmanipulation Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 4
4
* Author: lukasb1b (https://github.com/lukasb1b)
5
5
*/
6
6
7
- public class SingleBitOperators {
7
+ public class final SingleBitOperators {
8
8
/**
9
9
* Flip the bit at position 'bit' in 'num'
10
10
*/
11
- public static int flipBit (int num , int bit ) {
11
+ public static int flipBit (final int num , final int bit ) {
12
12
return num ^ (1 << bit );
13
13
}
14
14
/**
15
15
* Set the bit at position 'bit' to 1 in the 'num' variable
16
16
*/
17
- public static int setBit (int num , int bit ) {
17
+ public static int setBit (final int num ,final int bit ) {
18
18
return num | (1 << bit );
19
19
}
20
20
/**
21
21
* Clears the bit located at 'bit' from 'num'
22
22
*/
23
- public static int clearBit (int num , int bit ) {
23
+ public static int clearBit (final int num ,final int bit ) {
24
24
return num & ~(1 << bit );
25
25
}
26
26
/**
27
27
* Get the bit located at 'bit' from 'num'
28
28
*/
29
- public static int getBit (int num , int bit ) {
29
+ public static int getBit (final int num ,final int bit ) {
30
30
return ((num >> bit ) & 1 );
31
31
}
32
32
}
You can’t perform that action at this time.
0 commit comments