Is Even
by Isai Damier, Android Engineer @ Google

/**************************************************************************
 * Author: Isai Damier
 * Title: isEven
 * Project: geekviewpoint
 * Package: algorithms
 *
 * Statement:
 *   Indecate whether the given integer is even.
 *
 * Sample Input: 28
 * Sample Output: true
 * 
 * Technical Details: The lowest bit of an even number is 0.
 *    0 = 0; 2 = 10; 4 = 100; 6 = 110; 8 = 1000; etc.
 *    Therefore, x AND 1 should be 0 for all even numbers.
 *
 ************************************************************************/ 
 public boolean isEven(int x) {
  return 0 == (x & 1);
}
import org.junit.Test;
import static org.junit.Assert.*;

public class BitwiseTest {

  /**
   * Test of isEven method, of class Bitwise.
   */
  @Test
  public void testIsEven() {
    System.out.println(""isEven"");
    Bitwise bits = new Bitwise();
    for (int i = 0; i < 10000; i += 2) {
      assertTrue(bits.isEven(i));
    }
    for (int i = 1; i < 10000; i += 2) {
      assertFalse(bits.isEven(i));
    }
  }
}