Is Odd
by Isai Damier, Android Engineer @ Google

/*****************************************************************
 * Author: Isai Damier
 * Title: isEven
 * Project: geekviewpoint
 * Package: algorithms
 *
 * Statement:
 *   Indecate whether the given integer is odd.
 *
 * Sample Input: 29
 * Sample Output: true
 * 
 * Technical Details: The lowest bit of an odd number is 1:
 *    1 = 1; 3 = 11; 5 = 101; 7 = 111; 9 = 1001; etc.
 *    Therefore, x AND 1 should be 1 for all odd numbers.
 *
 ****************************************************************/ 
 public boolean isOdd(int x) {
  return 1 == (x & 1);
}
import org.junit.Test;
import static org.junit.Assert.*;

public class BitwiseTest {

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