Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

bit hacks java

public class Sample {
	public static void main(String[] args) {
		int x = 16;
		// Turn off the rightmost 1-bit in x
		int y = x & (x-1);
		System.out.println("After turning off rightmost 1-bit: "  + y); // 0
		x = 48;	
		// Isolate rightmost 1-bit in x
		y = x & (-x);
		System.out.println("After isolating rightmost 1-bit: " + y); // 16
		// Turn on the rightmost 0-bit
		y = x | (x+1);
		System.out.println("After turning on rightmost 0-bit: " + y); // 49 
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: removeAll hard code 
Java :: arrays.asLisy in java 
Java :: how to set lowered bezels in jlabel 
Java :: java string format .2f 
Java :: java list addAll stream() filtereted 
Java :: difference between premitive and non-premitive 
Java :: java product 1 to n 
Java :: spigot run code asynhronously 
Java :: set html text android java 
Java :: java create list with one element 
Java :: fizzbuzz java 
Java :: bungeecord plugin add configs 
Java :: how to restart activity in android 
Java :: java convert double to string 
Java :: java stream to list 
Java :: java key pressed 
Java :: How to efficiently find the middle node of a singly linked list without counting its nodes, in Java? 
Java :: get all number from string java 
Java :: java print type of object 
Java :: how to create textview programmatically in android 
Java :: spigot sounds 
Java :: java multiplication table nested loop 
Java :: set to list java 
Java :: infinity constatn in java 
Java :: how to solve simultaneous equations in mathematica 
Java :: onclick android 
Java :: get value textfield java 
Java :: spigot execute command as player 
Java :: how to change maven java version in po, 
Java :: read file in java 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =