org.hermit.utils
Class Bitwise

java.lang.Object
  extended by org.hermit.utils.Bitwise

public class Bitwise
extends java.lang.Object

A set of bit-twiddling utilities.

Author:
Ian Cameron Smith

Method Summary
static int bitrev(int j, int n)
          Reverse the lowest n bits of j.
static boolean isPowerOf2(int n)
          Returns true if the argument is power of 2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isPowerOf2

public static final boolean isPowerOf2(int n)
Returns true if the argument is power of 2.

Parameters:
n - The number to test.
Returns:
true if the argument is power of 2.

bitrev

public static final int bitrev(int j,
                               int n)
Reverse the lowest n bits of j. This function is useful in the Cooley–Tukey FFT algorithm, for example.

Parameters:
j - Number to be reversed.
n - Number of low-order bits of j which are significant and to be reversed.
Returns:
The lowest n bits of the input value j, reversed. The higher-order bits will be zero.