Source Code : Returns 16 bits from the long number.
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
Returns 16 bits from the long number.
/*
* 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;
/**
* Returns 16 bits from the long number.
*
* @param data
* @param offset one of 0 to 3
* @return
*/
public static int get16BitsAligned(long data, int offset) {
// Normalize offset
offset = offset%4;
//System.out.println("offset:"+offset);
// Align the mask
long mask = MASK_16_BITS << 16*offset;
//System.out.println("Mask:"+Long.toHexString(mask));
//System.out.println("Data:"+Long.toHexString(data));
// Get the bits
long result = data & mask;
// Put bits in position
return (int) (result >>> (16*offset));
}
}
Thank with us