Mega Code Archive

 
Categories / Java / Language Basics
 

Gets the a single bit of the target

/*  * 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 int MASK_BIT_1 = 0x1;      /**       * Gets the a single bit of the target.       *       * @param position       * @param target       * @return       */      public static int getBit(int position, int target) {         return (target >>> position) & MASK_BIT_1;      } }