Source Code : Sets a specific bit of an int.
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Sets a specific bit of an int.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package org.ancora.SharedLibrary;
/**
* Methods for bit manipulation.
*
* @author Joao Bispo
*/
public class Util{
private static final long MASK_16_BITS = 0xFFFFL;
private static final int MASK_BIT_1 = 0x1;
/**
* Sets a specific bit of an int.
*
* @param bit the bit to set. The least significant bit is bit 0
* @param target the integer where the bit will be set
* @return the updated value of the target
*/
public static int setBit(int bit, int target) {
// Create mask
int mask = 1 << bit;
// Set bit
return target | mask;
}
}
Thank with us